From 69b07fc2cad5cc8af5ccac4391619f1f4c6ee6a0 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Mon, 14 Jan 2019 19:45:00 +0530 Subject: [PATCH] general form changes --- .../business-info-group.component.ts | 2 +- .../business-info/business-info.component.ts | 2 +- .../other-applicant-details.component.html | 31 +++-- .../other-applicant-details.component.ts | 44 +++++-- .../general-info/general-info.component.html | 99 +++++++++++---- .../general-info/general-info.component.scss | 10 +- .../general-info/general-info.component.ts | 116 +++++++++++++++--- 7 files changed, 238 insertions(+), 66 deletions(-) diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info-group/business-info-group.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info-group/business-info-group.component.ts index c8bc1ac3a..99e3f9759 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info-group/business-info-group.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info-group/business-info-group.component.ts @@ -35,7 +35,7 @@ export class BusinessInfoGroupComponent implements OnInit { getCompanyListForBusiness(): void{ this._pd.getCompaniesListsForBusiness(this.pdid).subscribe(data=>{ 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); } }) } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.ts index c9ced44b8..e103aa3b3 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.ts @@ -68,6 +68,7 @@ export class BusinessInfoComponent implements OnInit { this.pdid = this.pd_all_details.pdmaster_details.pd_id; this.company_id = this.pd_all_details.company_id; 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.form_id = 13; this.notifier = notifier; @@ -1217,7 +1218,6 @@ export class BusinessInfoComponent implements OnInit { let total ; if(control.length > 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.updateValueAndValidity(); } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.html index ebbe223f5..69dee7761 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.html @@ -12,29 +12,40 @@ - + {{tl.name}} - - + + - -
-
+ + + + + + {{qual.qualification_name}} + + + +
+
Is Person Met
-
+
Is Applicant
+ + + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.ts index e95734f04..21d668228 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dialogue/other-applicant-details/other-applicant-details.component.ts @@ -11,25 +11,32 @@ import { PdTrigerService } from './../../../../../../pd-service/pd-triger.servic export class OtherApplicantDetailsComponent implements OnInit { pageTitle: string ="Add Name of Person(s) Met and Individual Loan Applicant(s) "; 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=[]; + qualificationList: any=[]; + constructor(private _fb: FormBuilder, private _pd: PdTrigerService, @Inject(MAT_DIALOG_DATA) public data: any, private dialogRef: MatDialogRef) { } ngOnInit() { this.initFormDetails(); - this.getTitleMaster(); + this.getMasterDetails('TITLES',1); + this.getMasterDetails('EDUQUALIFICATION',2); } - // get title master - getTitleMaster() { - let relation ="TITLES"; - this._pd.getAllMasterDatas(relation).subscribe( - data => { - if (data.status == 200) { - this.titleList=data.records.filter(val=>val.isactive==1); + + // get all master details + getMasterDetails(table:string,type:number){ + this._pd.getAllMasterDatas(table).subscribe( + data => { + if (data.status == 200) { + if(type==1){ + this.titleList=data.records.filter(val=>val.isactive==1); } - }); - - } + if(type==2){ + this.qualificationList = data.records; + } + } + }); + } // init form initFormDetails() { @@ -43,9 +50,11 @@ createApplicant(elementValue:any){ return this._fb.group({ pd_co_applicant_id: [elementValue.pd_co_applicant_id], applicant_title_name: [elementValue.applicant_title_name, Validators.required], - applicant_name:[''], + applicant_name:['',Validators.required], is_applicant:[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(); + } + } } 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 index b2a1c3961..d22fc0cef 100644 --- 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 @@ -38,18 +38,30 @@ --> - - + + Age + + + + + + Qualification + + + {{qual.qualification_name}} + + + - - @@ -60,22 +72,57 @@ Company/Firm - -
-
- - - - Is Applicant + +
+ + + + + + Is Applicant + + + + {{entity.business_entity_type_name}} + + + + + + + +

Number of Years For Which The Business Has Been Running

+ + + Please Enter Correct Year + + + + + + + + + + +
+
+ +
+
+
+
+
- - -
-
+ + + + @@ -83,7 +130,7 @@ - Personal Relationship + Relationship Between Individuals @@ -130,7 +177,7 @@ - Company/Firm Relationship + Relationship of Individuals to Company / Firm @@ -187,10 +234,10 @@ - - 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 index 8ef60e983..bd0c2ae7d 100644 --- 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 @@ -22,6 +22,7 @@ } .table-checkbox-com { margin-left: 3% !important; + //margin-top: 1% !important; } .p-text { color:#e00201 !important; @@ -29,4 +30,11 @@ } ::ng-deep .cdk-global-overlay-wrapper{ justify-content: center !important; -} \ No newline at end of file +} + +// .com-parent > *:not(:first-child) { +// margin-top: 3% !important; +// } +// .after-com-parent >*:not(:first-child) { +// margin-left: 3% !important; +// } \ No newline at end of file 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 index f32997448..e3f686532 100644 --- 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 @@ -6,12 +6,14 @@ import { PdTrigerService } from './../../../../../pd-service/pd-triger.service'; import {OtherApplicantDetailsComponent} from './../dialogue/other-applicant-details/other-applicant-details.component'; import { element } from '@angular/core/src/render3/instructions'; import { ELEMENT_PROBE_PROVIDERS } from '@angular/platform-browser/src/dom/debug/ng_probe'; +import { DatePipe } from '@angular/common'; @Component({ selector: 'app-general-info', templateUrl: './general-info.component.html', styleUrls: ['./general-info.component.scss'], }) export class GeneralInfoComponent implements OnInit { + pipe = new DatePipe('en-US'); pageTitle: string ="General Information"; pdid : string; form_id:number; @@ -19,7 +21,7 @@ export class GeneralInfoComponent implements OnInit { count : number = 1; private notifier: NotifierService; 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 relationSource= new MatTableDataSource(); public CompanySource = new MatTableDataSource(); @@ -32,21 +34,25 @@ export class GeneralInfoComponent implements OnInit { individualsList: any=[]; individualsListBothCase: 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,) { this.pdid = this.pd_all_details.pdmaster_details.pd_id; this.notifier = notifier; this.form_id = 18; 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() { + 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.getMasterDetails('RELATIONSHIPS',1); this.getMasterDetails('COMPANYRELATIONSHIPS',2); + this.getMasterDetails('EDUQUALIFICATION',3); + this.getMasterDetails('BUSINESSENTITYTYPE',4); // update data source table when change the individuals details this._generalForm.controls['individuals'].valueChanges.subscribe(val=>{ let control = 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.name != 'Others'); } + if(type==3){ + this.qualificationList = data.records; + } + if(type==4) { + this.businessEntityTypeList = data.records; + } } }, error => this.errorMessage = error); @@ -171,10 +183,19 @@ export class GeneralInfoComponent implements OnInit { if(exist_companies.length>0){ exist_companies.forEach((element,cindex) => { 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){ let control: any = this._generalForm.get('companies') as FormArray; control.controls[cindex].controls.company_name.clearValidators(); 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_person_met=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)); personsWithRelationshipsControl.push(this.createPersonsWithRelationships(element)); //let relationControl = this._generalForm.controls['applicant_relation']; @@ -217,13 +240,13 @@ export class GeneralInfoComponent implements OnInit { // create companies 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)) } }); // check company if null update one row 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)) } @@ -241,6 +264,8 @@ export class GeneralInfoComponent implements OnInit { is_person_met:[elementValue.is_person_met], is_new:[elementValue.is_new], individuals_order_id: [elementValue.individuals_order_id], + age: [elementValue.age], + qualification: [elementValue.qualification] }); } createPersonsWithRelationships(elementValue:any){ @@ -256,11 +281,16 @@ export class GeneralInfoComponent implements OnInit { createCompanies(elementValue:any) { return this._fb.group({ company_order_id: [elementValue.company_order_id], - company_name: [elementValue.company_name], + company_name: [elementValue.company_name,], company_messrs_name: ['M/s'], 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_new:[elementValue.is_new] + is_new:[elementValue.is_new], + }); } @@ -307,7 +337,7 @@ export class GeneralInfoComponent implements OnInit { // add more companies addMoreCompanies() { 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)) } @@ -316,9 +346,13 @@ export class GeneralInfoComponent implements OnInit { 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(); - control.controls[indexValues].controls.company_name.updateValueAndValidity(); + control.controls[indexValues].controls.is_active.setValue(false); + control.controls[indexValues].controls.company_name.clearValidators(); + 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); } @@ -441,6 +475,57 @@ export class GeneralInfoComponent implements OnInit { let control:any = 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); + } + + /** 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 @@ -469,6 +554,9 @@ export class GeneralInfoComponent implements OnInit { dataresult => { if (dataresult.status == 200) { this.notifier.notify('success', 'General Information Updated.!'); + setTimeout(() =>{ + this.dialog.closeAll(); + },1000); } else {