general changes : ps

This commit is contained in:
venbatechnologies@gmail.com 2019-01-05 14:05:38 +05:30
parent 99c8283f74
commit cfa3d9cb42
4 changed files with 284 additions and 52 deletions

View File

@ -78,7 +78,124 @@
<!-- companies end -->
<div fxLayout="row wrap" formArrayName="applicant_relation">
<!-- Person Relationship Starts Here -->
<mat-card>
<mat-card-header>
<mat-card-title> Person Relationship </mat-card-title>
</mat-card-header>
<mat-card-content>
<mat-table [dataSource]="relationSource" *ngIf="_generalForm.controls.persons_with_relationships['controls'].length>0" formArrayName="persons_with_relationships">
<ng-container matColumnDef="applicant_name">
<mat-header-cell *matHeaderCellDef> Name </mat-header-cell>
<mat-cell *matCellDef="let details;let i = index;" [formGroupName]="i">
{{details.value.applicant_name | titlecase}}
</mat-cell>
</ng-container>
<ng-container matColumnDef="relation">
<mat-header-cell *matHeaderCellDef> Relation </mat-header-cell>
<mat-cell *matCellDef="let details;let i = index;" [formGroupName]="i">
<mat-select placeholder="Relation" formControlName="relationship" style="width: 75%;">
<mat-option>Select</mat-option>
<mat-option [value]="member.relationship_id" *ngFor="let member of relationShipList">{{member.name + ' of' | titlecase}}</mat-option>
<mat-option value="0" > Not Applicable </mat-option>
</mat-select>
</mat-cell>
</ng-container>
<ng-container matColumnDef="relation_to">
<mat-header-cell *matHeaderCellDef> Relationship To </mat-header-cell>
<mat-cell *matCellDef="let details;let i = index;" [formGroupName]="i">
<mat-select placeholder="Applicant" formControlName="relation_to" style="width: 75%;">
<mat-option>Select</mat-option>
<mat-option *ngFor="let appc of individualsList" [value]="appc.pd_co_applicant_id">{{appc.applicant_name | titlecase}}</mat-option>
<mat-option value="0" > Not Applicable </mat-option>
</mat-select>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="secondDisplayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: secondDisplayedColumns;"></mat-row>
</mat-table>
</mat-card-content>
</mat-card>
<!-- Person Relationship Ends Here -->
<!-- company Relationship Start Here -->
<mat-card>
<mat-card-header>
<mat-card-title> Company/Firm Relationship </mat-card-title>
</mat-card-header>
<mat-card-content>
<mat-table [dataSource]="CompanySource" *ngIf="_generalForm.controls.company_with_relationships['controls'].length>0" formArrayName="company_with_relationships">
<ng-container matColumnDef="applicant_name">
<mat-header-cell *matHeaderCellDef> Applicant </mat-header-cell>
<mat-cell *matCellDef="let details;let i = index;" [formGroupName]="i">
<mat-select placeholder="Applicant" formControlName="applicant_name" style="width: 75%;">
<mat-option *ngFor="let appc of individualsList" [value]="appc.pd_co_applicant_id">{{appc.applicant_name | titlecase}}</mat-option>
</mat-select>
</mat-cell>
</ng-container>
<ng-container matColumnDef="company_relationship">
<mat-header-cell *matHeaderCellDef> Relation </mat-header-cell>
<mat-cell *matCellDef="let details;let i = index;" [formGroupName]="i">
<mat-select placeholder="Relation" formControlName="company_relationship" style="width: 75%;">
<mat-option>Select</mat-option>
<mat-option *ngFor="let comrelShip of companyRelationShipList" [value]="comrelShip.company_relationship_id">
{{comrelShip.name + ' of' | titlecase}}
</mat-option>
<mat-option value="0" > Not Applicable </mat-option>
</mat-select>
</mat-cell>
</ng-container>
<ng-container matColumnDef="relation_to_company">
<mat-header-cell *matHeaderCellDef> Company </mat-header-cell>
<mat-cell *matCellDef="let details;let i = index;" [formGroupName]="i">
<mat-select placeholder="Company / Firm" formControlName="relation_to_company" style="width: 75%;">
<mat-option>Select</mat-option>
<mat-option *ngFor="let comp of companyList" [value]="comp.company_order_id">
{{comp.company_name | titlecase}}
</mat-option>
<mat-option value="0" > Not Applicable </mat-option>
</mat-select>
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeCompanyRelationship(i)"
matTooltip="Remove Company Relationship" matTooltipPosition="below">
<mat-icon>delete</mat-icon>
</button>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="thridDisplayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: thridDisplayedColumns;">
</mat-row>
</mat-table>
</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)="addCompanyRelationshipDialogue()"
matTooltip="Add Company Relationship" matTooltipPosition="left" color="primary">
<mat-icon>add</mat-icon>
</button>
</mat-card-actions>
</mat-card>
<!-- Company RelationShip Ends Here -->
<!-- -- <div fxLayout="row wrap" formArrayName="applicant_relation">
<div fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100" *ngFor="let relation of _generalForm.controls.applicant_relation['controls']; let r = index;" [formGroupName]="r">
<mat-card >
<mat-card-header>
@ -98,7 +215,7 @@
</mat-select>
</mat-form-field>
<mat-form-field style="width: 20%">
<!--[placeholder]="placeholderName[i] != '' ? placeholderName[i] : 'Instalment Amount' "-->
<!--[placeholder]="placeholderName[i] != '' ? placeholderName[i] : 'Instalment Amount' "--
<mat-select placeholder="Relation" formControlName="relationship">
<mat-option>Select</mat-option>
<mat-option *ngFor="let relShip of relationShipList" [value]="relShip.relationship_id">
@ -117,8 +234,8 @@
</div>
</div>
</div>
<p>Company/Firm Relationship</p>
</div>-->
<!-- -- <p>Company/Firm Relationship</p>
<div formArrayName="multiple_company_relation">
<div fxLayout="row nowrap" *ngFor="let comRel of relation.get('multiple_company_relation').controls; let c = index" [formGroupName]="c">
<mat-form-field style="width: 40%">
@ -150,7 +267,7 @@
</mat-card-content>
</mat-card>
</div>
</div>
</div> -->
</mat-dialog-content>
<mat-dialog-actions>

View File

@ -15,10 +15,16 @@ export class GeneralInfoComponent implements OnInit {
pageTitle: string ="General Information";
pdid : string;
form_id:number;
is_new : boolean;
count : number = 1;
private notifier: NotifierService;
public _generalForm: FormGroup;
displayedColumns = ['applicant_name','is_person_met','is_applicant'];
public individualsSource= new MatTableDataSource();
public relationSource= new MatTableDataSource();
public CompanySource = new MatTableDataSource();
secondDisplayedColumns = ['applicant_name','relation','relation_to'];
thridDisplayedColumns = ['applicant_name','company_relationship','relation_to_company'];
public pd_applicants_details: any;
relationShipList:any=[];
companyRelationShipList:any=[];
@ -51,6 +57,19 @@ export class GeneralInfoComponent implements OnInit {
let control = <FormArray>this._generalForm.controls['companies'];
this.companyList = control.value.filter(element =>element.company_name && element.is_active);
});
this._generalForm.controls['persons_with_relationships'].valueChanges.subscribe(val=>{
let control = <FormArray>this._generalForm.controls['persons_with_relationships'];
this.relationSource.data =control.controls;
//this.individualsList = control.value.filter(element =>element.is_applicant===true);
});
// change relation with businees update dat sorce table
this._generalForm.controls['company_with_relationships'].valueChanges.subscribe(val=>{
let ComapnyControl = <FormArray>this._generalForm.controls['company_with_relationships'];
this.CompanySource .data =ComapnyControl.controls;
});
}
// init form
@ -58,11 +77,13 @@ export class GeneralInfoComponent implements OnInit {
this._generalForm = this._fb.group({
pdid:this.pdid,
formid:this.form_id,
applicant_relation: this._fb.array([]),
//applicant_relation: this._fb.array([]),
individuals: this._fb.array([]),
companies: this._fb.array([]),
persons_with_relationships: this._fb.array([]),
company_with_relationships: this._fb.array([]),
general_remark:''
});
})
this.loadFormData();
}
// get all master details
@ -72,10 +93,12 @@ export class GeneralInfoComponent implements OnInit {
if (data.status == 200) {
if(type==1){
this.relationShipList=data.records.filter(item => item.isactive == 1);
this.relationShipList.push({'relationship_id':"0",'name':'Others'});
//this.relationShipList.push({'relationship_id':"0",'name':'Not Applicable'});
}
if(type==2){
this.companyRelationShipList=data.records.filter(item => item.isactive == 1);
this.companyRelationShipList=data.records.filter(item => item.name != 'Others');
}
}
@ -89,13 +112,18 @@ export class GeneralInfoComponent implements OnInit {
params.pd_form_id = '18';
let individualsControl = <FormArray>this._generalForm.controls['individuals'];
let companyControl = this._generalForm.get('companies') as FormArray;
let relationControl = <FormArray>this._generalForm.controls['applicant_relation'];
//let relationControl = <FormArray>this._generalForm.controls['applicant_relation'];
let personsWithRelationshipsControl = <FormArray>this._generalForm.controls['persons_with_relationships'];
let companyWithRelationshipsControl = <FormArray>this._generalForm.controls['company_with_relationships'];
individualsControl.controls = [];
relationControl.controls = [];
//relationControl.controls = [];
companyControl.controls = [];
personsWithRelationshipsControl.controls = [];
let exist_individuals:any;
let exist_companies:any;
let exist_relation:any;
let exist_personsWithRelationships:any;
let exist_companyWithRelationships:any;
this._pd.retriveForm(params).subscribe(data => {
if(data.dataStatus) {
this._generalForm.controls['general_remark'].setValue(data.records.general_remark ? data.records.general_remark : '');
@ -110,6 +138,30 @@ export class GeneralInfoComponent implements OnInit {
individualsControl.push(this.createIndividulas(element))
});
}
// create persons with relationships
exist_personsWithRelationships=Object.keys(data.records.persons_with_relationships).map(function(key) {
return data.records.persons_with_relationships[key];
});
if(exist_personsWithRelationships.length>0){
exist_personsWithRelationships.forEach(element => {
//individualsControl.push(this.createIndividulas(element))
personsWithRelationshipsControl.push(this.createPersonsWithRelationships(element));
});
}
exist_companyWithRelationships=Object.keys(data.records.company_with_relationships).map(function(key) {
return data.records.company_with_relationships[key];
});
if(exist_companyWithRelationships.length>0){
exist_companyWithRelationships.forEach(element => {
//individualsControl.push(this.createIndividulas(element))
companyWithRelationshipsControl.push(this.createCompaniesRelationshipWithData(element));
});
}
// create companies
exist_companies = Object.keys(data.records.companies).map(function(key) {
return data.records.companies[key];
@ -127,37 +179,39 @@ export class GeneralInfoComponent implements OnInit {
}
// create relations
exist_relation = Object.keys(data.records.applicant_relation).map(function(key) {
return data.records.applicant_relation[key];
});
if(exist_relation.length>0){
exist_relation.forEach((element,index) => {
relationControl.push(this.createApplicantRelation(element));
let innerrelControl:any = relationControl.controls[index].get('multiple_relation') as FormArray;
element.multiple_relation.forEach((innereElement) => {
innerrelControl.push(this.createMultipleRelation(innereElement));
});
let innercomrelControl:any = relationControl.controls[index].get('multiple_company_relation') as FormArray;
element.multiple_company_relation.forEach((innerecomElement) => {
innercomrelControl.push(this.createMultipleCompanyRelation(innerecomElement));
});
});
}
// exist_relation = Object.keys(data.records.applicant_relation).map(function(key) {
// return data.records.applicant_relation[key];
// });
// if(exist_relation.length>0){
// exist_relation.forEach((element,index) => {
// relationControl.push(this.createApplicantRelation(element));
// let innerrelControl:any = relationControl.controls[index].get('multiple_relation') as FormArray;
// element.multiple_relation.forEach((innereElement) => {
// innerrelControl.push(this.createMultipleRelation(innereElement));
// });
// let innercomrelControl:any = relationControl.controls[index].get('multiple_company_relation') as FormArray;
// element.multiple_company_relation.forEach((innerecomElement) => {
// innercomrelControl.push(this.createMultipleCompanyRelation(innerecomElement));
// });
// });
// }
}
else {
this.pd_applicants_details.forEach((element,key) => {
element.is_applicant=true;
element.is_person_met=false;
element.is_new=false;
element.individuals_order_id = key+1
individualsControl.push(this.createIndividulas(element));
let relationControl = <FormArray>this._generalForm.controls['applicant_relation'];
let applicant_details: any= {'pd_co_applicant_id':element.pd_co_applicant_id,'applicant_name':element.applicant_name, 'individula_order_id':relationControl.controls.length+1};
relationControl.push(this.createApplicantRelation(applicant_details));
let mulRelationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_relation');
mulRelationControl.push(this.createMultipleRelation(applicant_details))
let mulCmyRelationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_company_relation');
mulCmyRelationControl.push(this.createMultipleCompanyRelation(applicant_details))
personsWithRelationshipsControl.push(this.createPersonsWithRelationships(element));
//let relationControl = <FormArray>this._generalForm.controls['applicant_relation'];
// let applicant_details: any= {'pd_co_applicant_id':element.pd_co_applicant_id,'applicant_name':element.applicant_name, 'individula_order_id':relationControl.controls.length+1};
// relationControl.push(this.createApplicantRelation(applicant_details));
// let mulRelationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_relation');
// mulRelationControl.push(this.createMultipleRelation(applicant_details))
// let mulCmyRelationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_company_relation');
// mulCmyRelationControl.push(this.createMultipleCompanyRelation(applicant_details))
// create companies
if(element.company_name!='' && element.company_name!=null){
@ -182,9 +236,17 @@ export class GeneralInfoComponent implements OnInit {
applicant_name: [elementValue.applicant_name],
is_applicant:[elementValue.is_applicant],
is_person_met:[elementValue.is_person_met],
is_new:[elementValue.is_new],
individuals_order_id: [elementValue.individuals_order_id],
});
}
createPersonsWithRelationships(elementValue:any){
return this._fb.group({
applicant_name: [elementValue.applicant_name],
relationship:[elementValue.relationship],
relation_to:[elementValue.relation_to],
});
}
// create companies
createCompanies(elementValue:any) {
return this._fb.group({
@ -194,6 +256,46 @@ export class GeneralInfoComponent implements OnInit {
});
}
// createCompaniesRelationship(elementValue:any) {
// return this._fb.group({
// applicant_name:[elementValue.applicant_name],
// company_relationship:[elementValue.company_relationship],
// relation_to_company:[elementValue.relation_to_company]
// });
// }
createCompaniesRelationship() {
return this._fb.group({
applicant_name:[''],
company_relationship:[''],
relation_to_company:['']
});
}
createCompaniesRelationshipWithData(elementValue:any) {
return this._fb.group({
applicant_name:[elementValue.applicant_name],
company_relationship:[elementValue.company_relationship],
relation_to_company:[elementValue.relation_to_company]
});
}
// open other family family member details
addCompanyRelationshipDialogue() {
let control: any = this._generalForm.get('company_with_relationships') as FormArray;
//let setValues: any = { applicant_name:'', company_relationship:'',relation_to_company:''};
control.push(this.createCompaniesRelationship())
}
// remove other famil membre
removeCompanyRelationship(indexValues){
let control: any = this._generalForm.get('company_with_relationships') as FormArray;
control.removeAt(indexValues);
// control.controls[indexValues].controls.company_name.clearValidators();
// control.controls[indexValues].controls.company_name.updateValueAndValidity();
//control.removeAt(indexValues);
}
// add more companies
addMoreCompanies() {
let control: any = this._generalForm.get('companies') as FormArray;
@ -203,6 +305,8 @@ export class GeneralInfoComponent implements OnInit {
// remove companies
removeCompanies(indexValues) {
this.count = this.count-1;
console.log('removed Count',this.count);
let control: any = this._generalForm.get('companies') as FormArray;
control.controls[indexValues].controls.is_active.setValue(false);
control.controls[indexValues].controls.company_name.clearValidators();
@ -279,6 +383,7 @@ export class GeneralInfoComponent implements OnInit {
// add more individuals details
addMoreIndividuals() {
console.log('Initial Count',this.count);
const dialogRef = this.dialog.open(OtherApplicantDetailsComponent, {
data: '',
width:'40%',
@ -287,17 +392,27 @@ export class GeneralInfoComponent implements OnInit {
dialogRef.afterClosed()
.subscribe(dataresult => {
if(dataresult.data.length>0){
dataresult.data.forEach(element => {
dataresult.data.forEach((element,index) => {
console.log('Foreach Entry Count',this.count);
let individualsControl = <FormArray>this._generalForm.controls['individuals'];
element.pd_co_applicant_id = this.count;
this.count = this.count+1;
element.individuals_order_id = individualsControl.controls.length+1;
element.is_new=true;
individualsControl.push(this.createIndividulas(element));
let relationControl = <FormArray>this._generalForm.controls['applicant_relation'];
let applicant_details: any= {'pd_co_applicant_id':element.pd_co_applicant_id,'applicant_name':element.applicant_name,'applicant_relation_to':'','relation':'','other_relation':'','company_name':'','company_relation':'','company_other_relation':'','individuals_order_id':element.individuals_order_id};
relationControl.push(this.createApplicantRelation(applicant_details));
let mulRelationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_relation');
mulRelationControl.push(this.createMultipleRelation(applicant_details))
let mulCmyRelationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_company_relation');
mulCmyRelationControl.push(this.createMultipleCompanyRelation(applicant_details))
console.log('Foreach Entry Count with Incremented',this.count);
console.log('Final Count',this.count);
let relationControl = <FormArray>this._generalForm.controls['persons_with_relationships'];
let applicant_details: any= {'applicant_name':element.applicant_name,'relationship':'','relation_to':''};
relationControl.push(this.createPersonsWithRelationships(applicant_details));
// let relationControl2 = <FormArray>this._generalForm.controls['applicant_relation'];
// let applicant_details2: any= {'pd_co_applicant_id':element.pd_co_applicant_id,'applicant_name':element.applicant_name,'applicant_relation_to':'','relation':'','other_relation':'','company_name':'','company_relation':'','company_other_relation':'','individuals_order_id':element.individuals_order_id};
// relationControl2.push(this.createApplicantRelation(applicant_details2));
// let mulRelationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_relation');
// mulRelationControl.push(this.createMultipleRelation(applicant_details))
// let mulCmyRelationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_company_relation');
// mulCmyRelationControl.push(this.createMultipleCompanyRelation(applicant_details))
});
}
@ -314,21 +429,26 @@ export class GeneralInfoComponent implements OnInit {
// submit form details
submitGeneralForm(formData:any) {
if (this._generalForm.invalid) {
console.log('if',this._generalForm.value);
this.validateAllFormFields(this._generalForm);
return;
}
else if(formData.applicant_relation.length==0){
this.notifier.notify('warning', 'Please Choose Name of Person Met.!');
}
// else if(formData.applicant_relation.length==0){
// console.log('else if',this._generalForm.value);
// this.notifier.notify('warning', 'Please Choose Name of Person Met.!');
// }
else{
console.log('else',this._generalForm.value);
let saveRecords:any = {}
saveRecords.pdid=formData.pdid;
saveRecords.formid=formData.formid;
saveRecords.individuals=formData.individuals;
saveRecords.companies=formData.companies;
saveRecords.applicant_relation=formData.applicant_relation;
saveRecords.persons_with_relationships=formData.persons_with_relationships;
saveRecords.company_with_relationships=formData.company_with_relationships;
//saveRecords.applicant_relation=formData.applicant_relation;
saveRecords.general_remark=formData.general_remark;
//console.log(saveRecords);
this._pd.savePDFormDetailsWithID(saveRecords).subscribe(
dataresult => {
if (dataresult.status == 200) {
@ -345,12 +465,7 @@ export class GeneralInfoComponent implements OnInit {
});
}
}
selectedApplicant(e,applicant_name){
console.log(e);
console.log(e.value);
console.log(e.viewValue);
console.log(applicant_name);
}
// selectedfrequency(e,i){
// switch(+e){
// case 1: this.placeholderName[i] = 'Weekly Instalment Amount'; break;