diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html
old mode 100755
new mode 100644
index 1f2a2a3d3..e6e6f6e03
--- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html
+++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html
@@ -77,8 +77,125 @@
+
+
+
+
+ Person Relationship
+
+
+ 0" formArrayName="persons_with_relationships">
+
+ Name
+
+
+ {{details.value.applicant_name | titlecase}}
+
+
+
+ Relation
+
+
+
+ Select
+ {{member.name + ' of' | titlecase}}
+ Not Applicable
+
+
+
+
+
+ Relationship To
+
+
+
+ Select
+ {{appc.applicant_name | titlecase}}
+ Not Applicable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Company/Firm Relationship
+
+
+
+
+
+ 0" formArrayName="company_with_relationships">
+
+
+ Applicant
+
+
+
+ {{appc.applicant_name | titlecase}}
+
+
+
+
+
+ Relation
+
+
+ Select
+
+ {{comrelShip.name + ' of' | titlecase}}
+
+ Not Applicable
+
+
+
+
+
+ Company
+
+
+
+ Select
+
+ {{comp.company_name | titlecase}}
+
+ Not Applicable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.scss
old mode 100755
new mode 100644
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.spec.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.spec.ts
old mode 100755
new mode 100644
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.ts
old mode 100755
new mode 100644
index 4461cf6b4..59f119594
--- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.ts
+++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.ts
@@ -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 = 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 = 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 = 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 = this._generalForm.controls['individuals'];
let companyControl = this._generalForm.get('companies') as FormArray;
- let relationControl = this._generalForm.controls['applicant_relation'];
+ //let relationControl = this._generalForm.controls['applicant_relation'];
+ let personsWithRelationshipsControl = this._generalForm.controls['persons_with_relationships'];
+ let companyWithRelationshipsControl = 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 = 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 = relationControl.controls[relationControl.controls.length-1].get('multiple_relation');
- mulRelationControl.push(this.createMultipleRelation(applicant_details))
- let mulCmyRelationControl = relationControl.controls[relationControl.controls.length-1].get('multiple_company_relation');
- mulCmyRelationControl.push(this.createMultipleCompanyRelation(applicant_details))
+ personsWithRelationshipsControl.push(this.createPersonsWithRelationships(element));
+ //let relationControl = 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 = relationControl.controls[relationControl.controls.length-1].get('multiple_relation');
+ // mulRelationControl.push(this.createMultipleRelation(applicant_details))
+ // let mulCmyRelationControl = 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 = 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 = 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 = relationControl.controls[relationControl.controls.length-1].get('multiple_relation');
- mulRelationControl.push(this.createMultipleRelation(applicant_details))
- let mulCmyRelationControl = 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 = 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 = 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 = relationControl.controls[relationControl.controls.length-1].get('multiple_relation');
+ // mulRelationControl.push(this.createMultipleRelation(applicant_details))
+ // let mulCmyRelationControl = 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;