general form changes

This commit is contained in:
gandhimathi 2019-01-14 19:45:00 +05:30
parent 3e81c45cde
commit 69b07fc2ca
7 changed files with 238 additions and 66 deletions

View File

@ -35,7 +35,7 @@ export class BusinessInfoGroupComponent implements OnInit {
getCompanyListForBusiness(): void{ getCompanyListForBusiness(): void{
this._pd.getCompaniesListsForBusiness(this.pdid).subscribe(data=>{ this._pd.getCompaniesListsForBusiness(this.pdid).subscribe(data=>{
if(data.dataStatus){ if(data.dataStatus){
this.existCompanyList = data.records.filter(val =>val.is_active); this.existCompanyList = data.records.filter(val =>val.is_active && val.is_company_applicant===true);
} }
}) })
} }

View File

@ -68,6 +68,7 @@ export class BusinessInfoComponent implements OnInit {
this.pdid = this.pd_all_details.pdmaster_details.pd_id; this.pdid = this.pd_all_details.pdmaster_details.pd_id;
this.company_id = this.pd_all_details.company_id; this.company_id = this.pd_all_details.company_id;
this.company_name = this.pd_all_details.company_name; this.company_name = this.pd_all_details.company_name;
this.pageTitle = this.pd_all_details.company_name;
this.applicants = this.pd_all_details.pdapplicants_detials; this.applicants = this.pd_all_details.pdapplicants_detials;
this.form_id = 13; this.form_id = 13;
this.notifier = notifier; this.notifier = notifier;
@ -1217,7 +1218,6 @@ export class BusinessInfoComponent implements OnInit {
let total ; let total ;
if(control.length > 0){ if(control.length > 0){
total = control.value.reduce((sum, val) => sum + +val.current_business_experiance_year, 0); total = control.value.reduce((sum, val) => sum + +val.current_business_experiance_year, 0);
console.log(total);
this.businessForm.controls.business_years.setValidators([Validators.required, Validators.min(+total)]); this.businessForm.controls.business_years.setValidators([Validators.required, Validators.min(+total)]);
this.businessForm.controls.business_years.updateValueAndValidity(); this.businessForm.controls.business_years.updateValueAndValidity();
} }

View File

@ -12,29 +12,40 @@
<mat-card *ngFor="let applicant of _OtherForm.controls.applicant_list['controls']; let r = index;" [formGroupName]="r"> <mat-card *ngFor="let applicant of _OtherForm.controls.applicant_list['controls']; let r = index;" [formGroupName]="r">
<mat-card-content> <mat-card-content>
<mat-form-field style="width: 30%"> <mat-form-field style="width: 30%">
<mat-select placeholder="Title" formControlName="applicant_title_name"> <mat-select placeholder="Title" formControlName="applicant_title_name" required>
<mat-option *ngFor="let tl of titleList" [value]="tl.title_id"> <mat-option *ngFor="let tl of titleList" [value]="tl.title_id">
{{tl.name}} {{tl.name}}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<mat-form-field style="width: 62%"> <mat-form-field style="width: 60%">
<input matInput placeholder="Name" formControlName="applicant_name" type="text"> <input matInput placeholder="Name" formControlName="applicant_name" type="text" required>
</mat-form-field> </mat-form-field>
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeApplicant(r)" *ngIf="r>0" <mat-form-field style="width: 30%">
matTooltip="Remove Individuals" matTooltipPosition="right"> <input matInput placeholder="age" formControlName="age" minlength="1" maxlength="3" (keypress)="keyPress($event)" autocomplete="off">
<mat-icon>delete</mat-icon> </mat-form-field>
</button> <mat-form-field style="width: 60%">
<div fxLayout="row wrap" class="example-section"> <mat-select placeholder="Qualification" formControlName="qualification" style="width: 75%;">
<div fxFlex="100%"> <mat-option *ngFor="let qual of qualificationList" [value]="qual.qualification_id">{{qual.qualification_name}}</mat-option>
</mat-select>
</mat-form-field>
<div fxLayout="row wrap">
<div fxFlex.xs="100%" fxFlex.sm="100%" fxFlex="45%">
<mat-checkbox class="example-margin" color="primary" formControlName="is_person_met">Is Person Met</mat-checkbox> <mat-checkbox class="example-margin" color="primary" formControlName="is_person_met">Is Person Met</mat-checkbox>
</div> </div>
<div fxFlex="100%"> <div fxFlex.xs="100%" fxFlex.sm="100%" fxFlex="45%">
<mat-checkbox class="example-margin" color="primary" formControlName="is_applicant">Is Applicant</mat-checkbox> <mat-checkbox class="example-margin" color="primary" formControlName="is_applicant">Is Applicant</mat-checkbox>
</div> </div>
</div> </div>
</mat-card-content> </mat-card-content>
<mat-card-actions align="end">
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeApplicant(r)" *ngIf="r>0"
matTooltip="Remove Individuals" matTooltipPosition="right">
<mat-icon>delete</mat-icon>
</button>
</mat-card-actions>
</mat-card> </mat-card>
</mat-dialog-content> </mat-dialog-content>

View File

@ -11,25 +11,32 @@ import { PdTrigerService } from './../../../../../../pd-service/pd-triger.servic
export class OtherApplicantDetailsComponent implements OnInit { export class OtherApplicantDetailsComponent implements OnInit {
pageTitle: string ="Add Name of Person(s) Met and Individual Loan Applicant(s) "; pageTitle: string ="Add Name of Person(s) Met and Individual Loan Applicant(s) ";
public _OtherForm: FormGroup; public _OtherForm: FormGroup;
applicantInfo:any={'pd_co_applicant_id':"0",'applicant_name':'','is_applicant':false,'is_person_met':false, applicant_title_name:''}; applicantInfo:any={'pd_co_applicant_id':"0",'applicant_name':'','is_applicant':false,'is_person_met':false, applicant_title_name:'',age:'', qualification:''};
titleList: any=[]; titleList: any=[];
qualificationList: any=[];
constructor(private _fb: FormBuilder, private _pd: PdTrigerService, @Inject(MAT_DIALOG_DATA) public data: any, private dialogRef: MatDialogRef<OtherApplicantDetailsComponent>) { } constructor(private _fb: FormBuilder, private _pd: PdTrigerService, @Inject(MAT_DIALOG_DATA) public data: any, private dialogRef: MatDialogRef<OtherApplicantDetailsComponent>) { }
ngOnInit() { ngOnInit() {
this.initFormDetails(); this.initFormDetails();
this.getTitleMaster(); this.getMasterDetails('TITLES',1);
this.getMasterDetails('EDUQUALIFICATION',2);
} }
// get title master
getTitleMaster() { // get all master details
let relation ="TITLES"; getMasterDetails(table:string,type:number){
this._pd.getAllMasterDatas(relation).subscribe( this._pd.getAllMasterDatas(table).subscribe(
data => { data => {
if (data.status == 200) { if (data.status == 200) {
this.titleList=data.records.filter(val=>val.isactive==1); if(type==1){
this.titleList=data.records.filter(val=>val.isactive==1);
} }
}); if(type==2){
this.qualificationList = data.records;
} }
}
});
}
// init form // init form
initFormDetails() { initFormDetails() {
@ -43,9 +50,11 @@ createApplicant(elementValue:any){
return this._fb.group({ return this._fb.group({
pd_co_applicant_id: [elementValue.pd_co_applicant_id], pd_co_applicant_id: [elementValue.pd_co_applicant_id],
applicant_title_name: [elementValue.applicant_title_name, Validators.required], applicant_title_name: [elementValue.applicant_title_name, Validators.required],
applicant_name:[''], applicant_name:['',Validators.required],
is_applicant:[false], is_applicant:[false],
is_person_met:[false], is_person_met:[false],
age:[''],
qualification: ['']
}); });
} }
@ -102,5 +111,14 @@ removeApplicant(intex:number){
} }
}); });
} }
/** On Key Press Event For Amount */
keyPress(event: any) {
const pattern = /[0-9]/;
let inputChar = String.fromCharCode(event.charCode);
if (event.keyCode != 8 && !pattern.test(inputChar)) {
event.preventDefault();
}
}
} }

View File

@ -38,18 +38,30 @@
</button> --> </button> -->
</mat-cell> </mat-cell>
</ng-container> </ng-container>
<ng-container matColumnDef="age">
<mat-header-cell *matHeaderCellDef> Age </mat-header-cell>
<mat-cell *matCellDef="let details;let i = index;" [formGroupName]="i">
<input matInput placeholder="Age" formControlName="age" minlength="1" maxlength="3" (keypress)="keyPress($event)" autocomplete="off">
</mat-cell>
</ng-container>
<ng-container matColumnDef="qualification">
<mat-header-cell *matHeaderCellDef> Qualification </mat-header-cell>
<mat-cell *matCellDef="let details;let i = index;" [formGroupName]="i">
<mat-select placeholder="Qualification" formControlName="qualification" style="width: 75%;">
<mat-option *ngFor="let qual of qualificationList" [value]="qual.qualification_id">{{qual.qualification_name}}</mat-option>
</mat-select>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"> <mat-row *matRowDef="let row; columns: displayedColumns;">
</mat-row> </mat-row>
</mat-table> </mat-table>
</mat-card-content> </mat-card-content>
<mat-card-actions align="end"> <mat-card-actions align="center">
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="addMoreIndividuals()" <button type="button"mat-flat-button (click)="addMoreIndividuals()"
matTooltip="Add More Person(s) Met/Applicant(s) " matTooltipPosition="left" color="primary"> matTooltip="Add More" matTooltipPosition="left" color="primary">
<mat-icon>add</mat-icon> <strong>Add More Person(s) </strong>
</button> </button>
</mat-card-actions> </mat-card-actions>
</mat-card> </mat-card>
@ -60,22 +72,57 @@
<mat-card-header> <mat-card-header>
<mat-card-title>Company/Firm</mat-card-title> <mat-card-title>Company/Firm</mat-card-title>
</mat-card-header> </mat-card-header>
<mat-card-content> <mat-card-content formArrayName="companies">
<div fxLayout="row wrap" formArrayName="companies"> <div *ngFor="let com of _generalForm.controls.companies['controls']; let c = index;" [formGroupName]="c">
<div fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100" *ngFor="let com of _generalForm.controls.companies['controls']; let c = index; let last = last;" [formGroupName]="c"> <mat-card *ngIf="com.value.is_active==true">
<mat-form-field style="width: 45%" *ngIf="com.value.is_active==true"> <mat-card-content>
<input matInput placeholder="Company/Firm" formControlName="company_name" type="text"> <mat-form-field style="width: 50%">
</mat-form-field> <input matInput placeholder="Company/Firm" formControlName="company_name" type="text">
<mat-checkbox class="table-checkbox-com" color="primary" formControlName="is_company_applicant"> Is Applicant</mat-checkbox> </mat-form-field>
<mat-checkbox class="table-checkbox-com" color="primary" formControlName="is_company_applicant"> Is Applicant</mat-checkbox>
<mat-form-field style="width: 45%;">
<mat-select placeholder="Business Entity Type"
formControlName="business_entity_type" (selectionChange)="checkEntityType(com.value.business_entity_type,c)" required>
<mat-option [value]="entity.business_entity_type_id" *ngFor="let entity of businessEntityTypeList">{{entity.business_entity_type_name}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 45%;" *ngIf="com.controls.business_entity_type_other">
<input matInput placeholder="Please Specify Others" formControlName="business_entity_type_other" required>
</mat-form-field>
<p>Number of Years For Which The Business Has Been Running</p>
<mat-form-field style="width: 20%;">
<input matInput placeholder="Year" formControlName="business_years" required autocomplete="off" (keypress)="keyPress($event)">
<mat-error>Please Enter Correct Year</mat-error>
</mat-form-field>
<mat-form-field style="width: 20%;">
<input matInput type="text" placeholder="Month" formControlName="business_month" autocomplete="off" (keypress)="keyPress($event)" (change)="ConvertMonthintoYearforBusiness($event.target.value,c)">
</mat-form-field>
<mat-form-field style="width: 40%;">
<input matInput [max]="maxDate" [matDatepicker]="picker" formControlName="business_date_object" (dateChange)="getDateObjects($event.target.value,c)" placeholder="Enter Date of Formation, If Available">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
<div fxLayout="row nowrap" [style.display]="'block'">
<div align="right">
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeCompanies(c)" *ngIf="com.value.is_active==true"
matTooltip="Remove Company/Firm" matTooltipPosition="above">
<mat-icon>delete</mat-icon>
</button>
</div>
</div>
</mat-card-content>
</mat-card>
</div>
<button type="button" class="mr-1 mb-1 hover-icon table-checkbox-com" mat-raised-button mat-icon-button (click)="removeCompanies(c)" *ngIf="c>0 && com.value.is_active==true"
matTooltip="Remove Company/Firm" matTooltipPosition="above">
<mat-icon>delete</mat-icon>
</button>
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Add More Company/Firm" matTooltipPosition="above" color="primary" (click)="addMoreCompanies()" *ngIf="last"><mat-icon>add</mat-icon></button>
</div>
</div>
</mat-card-content> </mat-card-content>
<mat-card-actions align="center">
<button mat-flat-button type="button" matTooltip="Add More" matTooltipPosition="above" color="primary" (click)="addMoreCompanies()"><strong>Add More Company/Firm</strong></button>
</mat-card-actions>
</mat-card> </mat-card>
<!-- companies end --> <!-- companies end -->
@ -83,7 +130,7 @@
<!-- Person Relationship Starts Here --> <!-- Person Relationship Starts Here -->
<mat-card> <mat-card>
<mat-card-header> <mat-card-header>
<mat-card-title> Personal Relationship </mat-card-title> <mat-card-title> Relationship Between Individuals </mat-card-title>
</mat-card-header> </mat-card-header>
<mat-card-content> <mat-card-content>
<mat-table [dataSource]="relationSource" *ngIf="_generalForm.controls.persons_with_relationships['controls'].length>0" formArrayName="persons_with_relationships"> <mat-table [dataSource]="relationSource" *ngIf="_generalForm.controls.persons_with_relationships['controls'].length>0" formArrayName="persons_with_relationships">
@ -130,7 +177,7 @@
<mat-card> <mat-card>
<mat-card-header> <mat-card-header>
<mat-card-title> Company/Firm Relationship </mat-card-title> <mat-card-title> Relationship of Individuals to Company / Firm </mat-card-title>
</mat-card-header> </mat-card-header>
<mat-card-content> <mat-card-content>
@ -187,10 +234,10 @@
</mat-table> </mat-table>
</mat-card-content> </mat-card-content>
<mat-card-actions align="end"> <mat-card-actions align="center">
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="addCompanyRelationshipDialogue()" <button type="button" mat-flat-button (click)="addCompanyRelationshipDialogue()"
matTooltip="Add Company Relationship" matTooltipPosition="left" color="primary"> matTooltip="Add More" matTooltipPosition="left" color="primary">
<mat-icon>add</mat-icon> <strong>Add More Company Relationship</strong>
</button> </button>
</mat-card-actions> </mat-card-actions>
</mat-card> </mat-card>

View File

@ -22,6 +22,7 @@
} }
.table-checkbox-com { .table-checkbox-com {
margin-left: 3% !important; margin-left: 3% !important;
//margin-top: 1% !important;
} }
.p-text { .p-text {
color:#e00201 !important; color:#e00201 !important;
@ -29,4 +30,11 @@
} }
::ng-deep .cdk-global-overlay-wrapper{ ::ng-deep .cdk-global-overlay-wrapper{
justify-content: center !important; justify-content: center !important;
} }
// .com-parent > *:not(:first-child) {
// margin-top: 3% !important;
// }
// .after-com-parent >*:not(:first-child) {
// margin-left: 3% !important;
// }

View File

@ -6,12 +6,14 @@ import { PdTrigerService } from './../../../../../pd-service/pd-triger.service';
import {OtherApplicantDetailsComponent} from './../dialogue/other-applicant-details/other-applicant-details.component'; import {OtherApplicantDetailsComponent} from './../dialogue/other-applicant-details/other-applicant-details.component';
import { element } from '@angular/core/src/render3/instructions'; import { element } from '@angular/core/src/render3/instructions';
import { ELEMENT_PROBE_PROVIDERS } from '@angular/platform-browser/src/dom/debug/ng_probe'; import { ELEMENT_PROBE_PROVIDERS } from '@angular/platform-browser/src/dom/debug/ng_probe';
import { DatePipe } from '@angular/common';
@Component({ @Component({
selector: 'app-general-info', selector: 'app-general-info',
templateUrl: './general-info.component.html', templateUrl: './general-info.component.html',
styleUrls: ['./general-info.component.scss'], styleUrls: ['./general-info.component.scss'],
}) })
export class GeneralInfoComponent implements OnInit { export class GeneralInfoComponent implements OnInit {
pipe = new DatePipe('en-US');
pageTitle: string ="General Information"; pageTitle: string ="General Information";
pdid : string; pdid : string;
form_id:number; form_id:number;
@ -19,7 +21,7 @@ export class GeneralInfoComponent implements OnInit {
count : number = 1; count : number = 1;
private notifier: NotifierService; private notifier: NotifierService;
public _generalForm: FormGroup; public _generalForm: FormGroup;
displayedColumns = ['applicant_name','is_person_met','is_applicant']; displayedColumns = ['applicant_name','is_person_met','is_applicant','age','qualification'];
public individualsSource= new MatTableDataSource(); public individualsSource= new MatTableDataSource();
public relationSource= new MatTableDataSource(); public relationSource= new MatTableDataSource();
public CompanySource = new MatTableDataSource(); public CompanySource = new MatTableDataSource();
@ -32,21 +34,25 @@ export class GeneralInfoComponent implements OnInit {
individualsList: any=[]; individualsList: any=[];
individualsListBothCase: any=[]; individualsListBothCase: any=[];
companyList: any=[]; companyList: any=[];
qualificationList: any=[];
businessEntityTypeList: any=[];
maxDate: any;
constructor(notifier: NotifierService,private _fb: FormBuilder,private _pd: PdTrigerService , private dialog: MatDialog, @Inject(MAT_DIALOG_DATA) public pd_all_details: any,) { constructor(notifier: NotifierService,private _fb: FormBuilder,private _pd: PdTrigerService , private dialog: MatDialog, @Inject(MAT_DIALOG_DATA) public pd_all_details: any,) {
this.pdid = this.pd_all_details.pdmaster_details.pd_id; this.pdid = this.pd_all_details.pdmaster_details.pd_id;
this.notifier = notifier; this.notifier = notifier;
this.form_id = 18; this.form_id = 18;
this.pd_applicants_details = this.pd_all_details.pdapplicants_detials; this.pd_applicants_details = this.pd_all_details.pdapplicants_detials;
// push Other options to applicant details
// this.pd_applicants_details.push({'pd_co_applicant_id':"0",'applicant_name':'Others', });
} }
ngOnInit() { ngOnInit() {
let get_max_date = this.pd_all_details.pdmaster_details.pd_date_of_initiation.split('/').reverse().join("/");
this.maxDate = new Date(get_max_date);
this.initFormDetails(); this.initFormDetails();
this.getMasterDetails('RELATIONSHIPS',1); this.getMasterDetails('RELATIONSHIPS',1);
this.getMasterDetails('COMPANYRELATIONSHIPS',2); this.getMasterDetails('COMPANYRELATIONSHIPS',2);
this.getMasterDetails('EDUQUALIFICATION',3);
this.getMasterDetails('BUSINESSENTITYTYPE',4);
// update data source table when change the individuals details // update data source table when change the individuals details
this._generalForm.controls['individuals'].valueChanges.subscribe(val=>{ this._generalForm.controls['individuals'].valueChanges.subscribe(val=>{
let control = <FormArray>this._generalForm.controls['individuals']; let control = <FormArray>this._generalForm.controls['individuals'];
@ -102,6 +108,12 @@ export class GeneralInfoComponent implements OnInit {
this.companyRelationShipList=data.records.filter(item => item.isactive == 1); this.companyRelationShipList=data.records.filter(item => item.isactive == 1);
this.companyRelationShipList=data.records.filter(item => item.name != 'Others'); this.companyRelationShipList=data.records.filter(item => item.name != 'Others');
} }
if(type==3){
this.qualificationList = data.records;
}
if(type==4) {
this.businessEntityTypeList = data.records;
}
} }
}, error => this.errorMessage = <any> error); }, error => this.errorMessage = <any> error);
@ -171,10 +183,19 @@ export class GeneralInfoComponent implements OnInit {
if(exist_companies.length>0){ if(exist_companies.length>0){
exist_companies.forEach((element,cindex) => { exist_companies.forEach((element,cindex) => {
companyControl.push(this.createCompanies(element)); companyControl.push(this.createCompanies(element));
let otherControl: any = this._generalForm.get('companies') as FormArray;
otherControl = otherControl.controls[cindex];
element.business_entity_type=='1' ? otherControl.addControl('business_entity_type_other', new FormControl(element.business_entity_type_other, Validators.required)) : otherControl.removeControl('business_entity_type_other');
if(element.is_active==false){ if(element.is_active==false){
let control: any = this._generalForm.get('companies') as FormArray; let control: any = this._generalForm.get('companies') as FormArray;
control.controls[cindex].controls.company_name.clearValidators(); control.controls[cindex].controls.company_name.clearValidators();
control.controls[cindex].controls.company_name.updateValueAndValidity(); control.controls[cindex].controls.company_name.updateValueAndValidity();
control.controls[cindex].controls.business_years.clearValidators();
control.controls[cindex].controls.business_years.updateValueAndValidity();
control.controls[cindex].controls.business_entity_type.clearValidators();
control.controls[cindex].controls.business_entity_type.updateValueAndValidity();
element.business_entity_type=='1' ? control.controls[cindex].controls.business_entity_type_other.clearValidators() : '';
element.business_entity_type=='1' ? control.controls[cindex].controls.business_entity_type_other.updateValueAndValidity() : '';
} }
}); });
@ -204,7 +225,9 @@ export class GeneralInfoComponent implements OnInit {
element.is_applicant=true; element.is_applicant=true;
element.is_person_met=false; element.is_person_met=false;
element.is_new=false; element.is_new=false;
element.individuals_order_id = key+1 element.individuals_order_id = key+1;
element.age = '',
element.qualification = '',
individualsControl.push(this.createIndividulas(element)); individualsControl.push(this.createIndividulas(element));
personsWithRelationshipsControl.push(this.createPersonsWithRelationships(element)); personsWithRelationshipsControl.push(this.createPersonsWithRelationships(element));
//let relationControl = <FormArray>this._generalForm.controls['applicant_relation']; //let relationControl = <FormArray>this._generalForm.controls['applicant_relation'];
@ -217,13 +240,13 @@ export class GeneralInfoComponent implements OnInit {
// create companies // create companies
if(element.company_name!='' && element.company_name!=null){ if(element.company_name!='' && element.company_name!=null){
let setCompanyValues: any = {company_order_id :companyControl.controls.length+1,company_name:element.company_name,is_company_applicant:element.is_company_applicant,is_active:true} let setCompanyValues: any = {company_order_id :companyControl.controls.length+1,company_name:element.company_name,is_company_applicant:element.is_company_applicant,business_entity_type:element.business_entity_type,business_entity_type_other:element.business_entity_type_other,business_years:element.business_years,business_month:element.business_month,business_date_object:element.business_date_object,is_new:element.is_new,is_active:true}
companyControl.push(this.createCompanies(setCompanyValues)) companyControl.push(this.createCompanies(setCompanyValues))
} }
}); });
// check company if null update one row // check company if null update one row
if(companyControl.controls.length ==0){ if(companyControl.controls.length ==0){
let setCompanyValues: any = {company_order_id :companyControl.controls.length+1,company_name:'',is_company_applicant:false,is_active:true,is_new:false} let setCompanyValues: any = {company_order_id :companyControl.controls.length+1,company_name:'',is_company_applicant:false,business_entity_type:'',business_entity_type_other:'',business_years:'',business_month:'',business_date_object:'',is_active:true,is_new:false}
companyControl.push(this.createCompanies(setCompanyValues)) companyControl.push(this.createCompanies(setCompanyValues))
} }
@ -241,6 +264,8 @@ export class GeneralInfoComponent implements OnInit {
is_person_met:[elementValue.is_person_met], is_person_met:[elementValue.is_person_met],
is_new:[elementValue.is_new], is_new:[elementValue.is_new],
individuals_order_id: [elementValue.individuals_order_id], individuals_order_id: [elementValue.individuals_order_id],
age: [elementValue.age],
qualification: [elementValue.qualification]
}); });
} }
createPersonsWithRelationships(elementValue:any){ createPersonsWithRelationships(elementValue:any){
@ -256,11 +281,16 @@ export class GeneralInfoComponent implements OnInit {
createCompanies(elementValue:any) { createCompanies(elementValue:any) {
return this._fb.group({ return this._fb.group({
company_order_id: [elementValue.company_order_id], company_order_id: [elementValue.company_order_id],
company_name: [elementValue.company_name], company_name: [elementValue.company_name,],
company_messrs_name: ['M/s'], company_messrs_name: ['M/s'],
is_company_applicant:[elementValue.is_company_applicant], is_company_applicant:[elementValue.is_company_applicant],
business_entity_type :[elementValue.business_entity_type,Validators.required],
business_years: [elementValue.business_years, Validators.required],
business_month: [elementValue.business_month],
business_date_object: [elementValue.business_date_object],
is_active: [elementValue.is_active], is_active: [elementValue.is_active],
is_new:[elementValue.is_new] is_new:[elementValue.is_new],
}); });
} }
@ -307,7 +337,7 @@ export class GeneralInfoComponent implements OnInit {
// add more companies // add more companies
addMoreCompanies() { addMoreCompanies() {
let control: any = this._generalForm.get('companies') as FormArray; let control: any = this._generalForm.get('companies') as FormArray;
let setValues: any = {company_order_id :control.controls.length+1,company_name:'',is_company_applicant:false,is_active:true,is_new: true} let setValues: any = {company_order_id :control.controls.length+1,company_name:'',is_company_applicant:false,business_entity_type:'',business_entity_type_other:'',business_years:'',business_month:'',business_date_object:'',is_active:true,is_new: true}
control.push(this.createCompanies(setValues)) control.push(this.createCompanies(setValues))
} }
@ -316,9 +346,13 @@ export class GeneralInfoComponent implements OnInit {
this.count = this.count-1; this.count = this.count-1;
// console.log('removed Count',this.count); // console.log('removed Count',this.count);
let control: any = this._generalForm.get('companies') as FormArray; let control: any = this._generalForm.get('companies') as FormArray;
control.controls[indexValues].controls.is_active.setValue(false); control.controls[indexValues].controls.is_active.setValue(false);
control.controls[indexValues].controls.company_name.clearValidators(); control.controls[indexValues].controls.company_name.clearValidators();
control.controls[indexValues].controls.company_name.updateValueAndValidity(); control.controls[indexValues].controls.company_name.updateValueAndValidity();
control.controls[indexValues].controls.business_years.clearValidators();
control.controls[indexValues].controls.business_years.updateValueAndValidity();
control.controls[indexValues].controls.business_entity_type.clearValidators();
control.controls[indexValues].controls.business_entity_type.updateValueAndValidity();
//control.removeAt(indexValues); //control.removeAt(indexValues);
} }
@ -441,6 +475,57 @@ export class GeneralInfoComponent implements OnInit {
let control:any = <FormArray>this._generalForm.controls['company_with_relationships']; let control:any = <FormArray>this._generalForm.controls['company_with_relationships'];
control.controls[indexVal].value.company_relationship==0 ? control.controls[indexVal].controls['relation_to_company'].setValue('') : control.controls[indexVal].controls['relation_to_company'].setValue(control.controls[indexVal].value.relation_to_company); control.controls[indexVal].value.company_relationship==0 ? control.controls[indexVal].controls['relation_to_company'].setValue('') : control.controls[indexVal].controls['relation_to_company'].setValue(control.controls[indexVal].value.relation_to_company);
}
/** On Key Press Event For Amount */
keyPress(event: any) {
const pattern = /[0-9]/;
let inputChar = String.fromCharCode(event.charCode);
if (event.keyCode != 8 && !pattern.test(inputChar)) {
event.preventDefault();
}
}
// convert mkonth to year business has been running
ConvertMonthintoYearforBusiness(e,controlIndex){
let control: any = this._generalForm.get('companies') as FormArray;
control = control.controls[controlIndex];
let business_year = control.controls.business_years.value;
let converted_month : number = e%12;
let converted_year : number = e/12;
control.controls.business_years.setValue(+business_year + +Math.floor(converted_year));
control.controls.business_month.setValue(Math.floor(converted_month));
}
getDateObjects(values: any, controlIndex) {
let control: any = this._generalForm.get('companies') as FormArray;
control = control.controls[controlIndex];
let pd_initiation_date:string = this.pd_all_details.pdmaster_details.pd_date_of_initiation.split('/').reverse().join("/");
let selected_date = this.pipe.transform(values, 'yyyy/MM/dd'); ;
let diffInMs: number = Date.parse(pd_initiation_date) - Date.parse(selected_date);
let diff: number = Math.floor(diffInMs / 1000);
diff /= (60 * 60 * 24 * 30);
diff=Math.abs(Math.round(diff));
control.controls['business_years'].setValue(0);
control.controls['business_month'].setValue(0);
if(diff){
control.controls['business_years'].setValue(Math.floor(diff / 12));
control.controls['business_month'].setValue(Math.floor(diff % 12));
}
}
// check entity type and create other form control
checkEntityType(value,controlIndex) {
let control: any = this._generalForm.get('companies') as FormArray;
control = control.controls[controlIndex];
value=='1' ? control.addControl('business_entity_type_other', new FormControl('', Validators.required)) : control.removeControl('business_entity_type_other');
} }
// submit form details // submit form details
@ -469,6 +554,9 @@ export class GeneralInfoComponent implements OnInit {
dataresult => { dataresult => {
if (dataresult.status == 200) { if (dataresult.status == 200) {
this.notifier.notify('success', 'General Information Updated.!'); this.notifier.notify('success', 'General Information Updated.!');
setTimeout(() =>{
this.dialog.closeAll();
},1000);
} }
else { else {