diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.html index c435cd69f..a318ff1b6 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.html @@ -128,53 +128,61 @@ Address Details - - + + - + - + - - - Select - + + Select {{SL.name}} - - + Select - - {{CL.city_name}} - - + + {{CL.city_name}} + - + - + - + Select - {{PL.pincode}} + {{PL.pincode}} - + + - Enter Valid Pincode. + - - - + 1"> + delete + + + + + + + + + add + + @@ -182,6 +190,7 @@ Applicant Details + Applicant 1 @@ -212,70 +221,63 @@ Enter Valid LandLine Number. + + + + + + + {{coDetails.controls.label.value}} {{i+2}} + + + + + + {{tl.name}} + + + + + + + + - - + + + + + + + + + Enter Valid Mobile Number. + + + + + Enter Valid STD Code. + - + + + Enter Valid Landline Number. + + + + delete + + + + - - - + + + group_add + - - Additional Requirements @@ -352,90 +354,4 @@ - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.ts index 0b550386e..1854ccaaa 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/add-pd/add-pd.component.ts @@ -23,15 +23,18 @@ export class AddPdComponent implements OnInit, OnDestroy { PDTriggerStatus: string; private notifier: NotifierService; public _PDtriggerForm: FormGroup; - items: FormArray; + + addresses: FormArray; + coapplicants: FormArray; addtional_requirements: FormArray; + productList: any; subProductList: any; lenderList: any; lenderBranchList: any; customerSegmentList: any; - stateList: any; - cityList: any; + stateList: any = []; + cityList: any = []; pdTypeList: any; billingList: any; relationShipList: any; @@ -43,6 +46,7 @@ export class AddPdComponent implements OnInit, OnDestroy { createWithLongContent = false; dynamicCoApplicant = []; disableAfterSubmit: boolean; + pincodeflag : any = []; constructor(notifier: NotifierService, private _fb: FormBuilder, private route: ActivatedRoute, private router: Router, private _pd: PdTrigerService, private _aws: AwsService, private ListPdComponent: ListPdComponent) { this.notifier = notifier; @@ -92,26 +96,21 @@ export class AddPdComponent implements OnInit, OnDestroy { applicant_stdcode: [null, Validators.compose([Validators.minLength(3), Validators.maxLength(5), Validators.pattern('^[0-9]*$')])], applicant_landline: [null, Validators.compose([Validators.minLength(6), Validators.maxLength(8), Validators.pattern('^[0-9]*$')])], company_name: [null], - addressline1: [null], - fk_city: [null], - fk_state: [null], - pincode: [null],/** ,Validators.compose([Validators.minLength(6),Validators.maxLength(6)]) */ - other_pincode: [null, Validators.compose([Validators.minLength(6), Validators.maxLength(6)])], remarks: [null], // allocation_type: [null], // sub_allocation_type: [null], - items: this._fb.array([]), + coapplicants: this._fb.array([]), + addresses: this._fb.array([this.createAddresses()]), documents: this._fb.array([]), addtional_requirements: this._fb.array([this.createRequiremnt()]) }); } + + /** FOR Dropdowns */ selectedLender(lender) { - // console.log(JSON.stringify(lender)); - // alert(JSON.stringify(lender['branches '])); this.lenderBranchList = lender['branches']; this._PDtriggerForm.controls.pd_branch_id.setValue(null); - } getLenderList() { @@ -122,6 +121,7 @@ export class AddPdComponent implements OnInit, OnDestroy { } }, error => this.errorMessage = error); } + getProductsList() { this._pd.getProductsDetails().subscribe( data => { @@ -131,6 +131,7 @@ export class AddPdComponent implements OnInit, OnDestroy { } }, error => this.errorMessage = error); } + getCustomerSegmentList() { this._pd.getCustomersDetails().subscribe( data => { @@ -139,14 +140,8 @@ export class AddPdComponent implements OnInit, OnDestroy { } }, error => this.errorMessage = error); } - // getStateCityList(){ - // this._pd.getStateCityDetails().subscribe( - // data => { - // if (data.status == 200) { - // this.stateList=data.records - // } - // }, error => this.errorMessage = error); - // } + + //get State getStateCityList() { this._pd.getAllMasterDatas('STATE').subscribe( data => { @@ -155,6 +150,8 @@ export class AddPdComponent implements OnInit, OnDestroy { } }); } + + //get PDType List getPDTypeList() { this._pd.getPDTypeDetails().subscribe( data => { @@ -164,31 +161,21 @@ export class AddPdComponent implements OnInit, OnDestroy { } }, error => this.errorMessage = error); } + //get sub product list based on prokduct id getSubproductList(productID: string) { - this.subProductList = this.productList.filter(item => item.product_id == productID); this.subProductList = this.subProductList[0].subproducts; this.subProductList = this.subProductList.filter(item => item.is_others == 0); } - // get city list details based on state id - // getCityList(stateID:string){ - // console.log(this.cityList); - // this.cityList= this.stateList.filter(item => item.state_id == stateID); - // console.log(this.cityList); - // this.cityList=this.cityList[0].cities; - // console.log(this.cityList); - // } //get city list details based on state id - getCityList(stateID: string) { - // console.log('getCityList',stateID); + getCityList(stateID: string,index) { this._pd.getStateWiseCities(stateID).subscribe(data => { if (data.status == 200) { - // console.log(data); - this.cityList = data.records.cities; - this.pincodeList = data.records.pincode; + this.cityList[index] = data.records.cities; + this.pincodeList[index] = data.records.pincode; } }); } @@ -200,10 +187,10 @@ export class AddPdComponent implements OnInit, OnDestroy { data => { if (data.status == 200) { this.relationShipList = data.records; - } }, error => this.errorMessage = error); } + // get title master getTitleMaster() { let relation = "TITLES"; @@ -211,31 +198,11 @@ export class AddPdComponent implements OnInit, OnDestroy { data => { if (data.status == 200) { this.titleList = data.records.filter(val => val.isactive == 1); - // console.log(this.titleList); - // let index1 = this.titleList.map(data => data.name).indexOf("Master"); - // this.titleList.splice(index1, 1); } }, error => this.errorMessage = error); - - } - createItem(): FormGroup { - return this._fb.group({ - - coapplicantName: [null, Validators.compose([Validators.required])], - // coapplicantTitleName: [null], - // companyName: [null], - // applicantType: 0, - // coapplicant_mobile_no: [null, Validators.compose([Validators.minLength(10), Validators.maxLength(10), Validators.required])], - // coapplicant_landline: [null, Validators.compose([Validators.minLength(12), Validators.maxLength(13)])], - // relationship: [null], - }); - }; - - addCoApplicant() { - this.items = this._PDtriggerForm.get('items') as FormArray; - this.items.push(this.createItem()); } + /** FOR Documents */ addMoreDocs() { if (this.totalfiles.length != 0) { if (this.documents.value[0].doc_name != "" && ((this.lengthCheckToaddMore) === (this.totalfiles.length))) { @@ -259,15 +226,11 @@ export class AddPdComponent implements OnInit, OnDestroy { get documents(): FormArray { return this._PDtriggerForm.get('documents') as FormArray; }; + get pdMain() { return this._PDtriggerForm.controls; } - // get pdCoApplicant() { return this._PDtriggerForm.get('items') as FormArray; } - removeCoApplicant(i: number) { - const control = this._PDtriggerForm.controls['items']; - control.removeAt(i); - } removeItem(index: number) { this.totalfiles.splice(index, 1); this.totalFileName.splice(index, 1); @@ -275,6 +238,53 @@ export class AddPdComponent implements OnInit, OnDestroy { this.lengthCheckToaddMore = this.lengthCheckToaddMore - 1; } + /** FOR Coapplicant */ + get pdCoApplicant() { return this._PDtriggerForm.get('coapplicants') as FormArray; } + + addCoApplicant() { + this.coapplicants = this._PDtriggerForm.get('coapplicants') as FormArray; + this.coapplicants.push(this.createCoApplicant()); + } + + createCoApplicant(): FormGroup { + return this._fb.group({ + label: ['Applicant'], + applicant_title_name:[null], + coapplicant_name: [null, Validators.compose([Validators.required])], + coapplicant_mobile_no: [null,Validators.compose([Validators.minLength(10),Validators.maxLength(10),Validators.required])], + coapplicant_stdcode:[null, Validators.compose([Validators.minLength(3), Validators.maxLength(5), Validators.pattern('^[0-9]*$')])], + coapplicant_landline : [null,Validators.compose([Validators.minLength(12),Validators.maxLength(13)])], + company_name:[null], + relationship: [null], + }); + }; + + removeCoApplicant(i: number) { + const control = this._PDtriggerForm.controls['coapplicants']; + control.removeAt(i); + } + + /** FOr Adress */ + get pdAddresses() { return this._PDtriggerForm.get('addresses') as FormArray; } + createAddresses(): FormGroup { + return this._fb.group({ + addressline: [null], + fk_city: [null], + fk_state: [null], + pincode: [null],/** ,Validators.compose([Validators.minLength(6),Validators.maxLength(6)]) */ + other_pincode: [null, Validators.compose([Validators.minLength(6), Validators.maxLength(6)])], + }); + }; + addAddresses() { + this.addresses = this._PDtriggerForm.get('addresses') as FormArray; + this.addresses.push(this.createAddresses()); + } + + removeAddresses(index: number) { + const address_control = this._PDtriggerForm.controls['addresses']; + address_control.removeAt(index); + } + get pdRequirements() { return this._PDtriggerForm.get('addtional_requirements') as FormArray; } createRequiremnt(): FormGroup { return this._fb.group({ @@ -317,7 +327,8 @@ export class AddPdComponent implements OnInit, OnDestroy { this.lengthCheckToaddMore = 1; } } - + getPincode(e,i){ this.pincodeflag[i] = e == 1 ? true : false; + } // save pd in draft saveDraftPD(formValue: any, status: string) { //alert('Inside The Draft PD'); @@ -351,17 +362,17 @@ export class AddPdComponent implements OnInit, OnDestroy { this._PDtriggerForm.controls['mobile_no'].setValidators([Validators.required]); this._PDtriggerForm.controls['mobile_no'].updateValueAndValidity(); - this._PDtriggerForm.controls['addressline1'].setValidators([Validators.required]); - this._PDtriggerForm.controls['addressline1'].updateValueAndValidity(); + // this._PDtriggerForm.controls['addressline1'].setValidators([Validators.required]); + // this._PDtriggerForm.controls['addressline1'].updateValueAndValidity(); - this._PDtriggerForm.controls['fk_city'].setValidators([Validators.required]); - this._PDtriggerForm.controls['fk_city'].updateValueAndValidity(); + // this._PDtriggerForm.controls['fk_city'].setValidators([Validators.required]); + // this._PDtriggerForm.controls['fk_city'].updateValueAndValidity(); - this._PDtriggerForm.controls['fk_state'].setValidators([Validators.required]); - this._PDtriggerForm.controls['fk_state'].updateValueAndValidity(); + // this._PDtriggerForm.controls['fk_state'].setValidators([Validators.required]); + // this._PDtriggerForm.controls['fk_state'].updateValueAndValidity(); - this._PDtriggerForm.controls['pincode'].setValidators([Validators.required]); - this._PDtriggerForm.controls['pincode'].updateValueAndValidity(); + // this._PDtriggerForm.controls['pincode'].setValidators([Validators.required]); + // this._PDtriggerForm.controls['pincode'].updateValueAndValidity(); setTimeout(() => { this.clearCustomValidatorFields(); }, 10000); @@ -397,23 +408,28 @@ export class AddPdComponent implements OnInit, OnDestroy { this._PDtriggerForm.controls['mobile_no'].clearValidators(); this._PDtriggerForm.controls['mobile_no'].updateValueAndValidity(); - this._PDtriggerForm.controls['addressline1'].clearValidators(); - this._PDtriggerForm.controls['addressline1'].updateValueAndValidity(); + // this._PDtriggerForm.controls['addressline1'].clearValidators(); + // this._PDtriggerForm.controls['addressline1'].updateValueAndValidity(); - this._PDtriggerForm.controls['fk_city'].clearValidators(); - this._PDtriggerForm.controls['fk_city'].updateValueAndValidity(); + // this._PDtriggerForm.controls['fk_city'].clearValidators(); + // this._PDtriggerForm.controls['fk_city'].updateValueAndValidity(); - this._PDtriggerForm.controls['fk_state'].clearValidators(); - this._PDtriggerForm.controls['fk_state'].updateValueAndValidity(); + // this._PDtriggerForm.controls['fk_state'].clearValidators(); + // this._PDtriggerForm.controls['fk_state'].updateValueAndValidity(); - this._PDtriggerForm.controls['pincode'].clearValidators(); - this._PDtriggerForm.controls['pincode'].updateValueAndValidity(); + // this._PDtriggerForm.controls['pincode'].clearValidators(); + // this._PDtriggerForm.controls['pincode'].updateValueAndValidity(); this.validateAllFormFields(this._PDtriggerForm); } // common function for both draft and process pd submitPdDetails(formValue: any, status: string) { + + console.log('formValue',formValue); + console.log('formValue.addresses',formValue.addresses); + console.log('formValue.addresses[0].addressline',formValue.addresses[0].addressline); + if (this._PDtriggerForm.invalid) { this.validateAllFormFields(this._PDtriggerForm); this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); @@ -426,30 +442,32 @@ export class AddPdComponent implements OnInit, OnDestroy { } else { this.disableAfterSubmit = true; - let concat_landline - let concat_landline1 + + let lender_landline_no; + let applicant_landline_no; + if (formValue.lender_stdcode != null || formValue.lender_landline != null) { if (formValue.lender_stdcode != '' && formValue.lender_landline != '') { - concat_landline = formValue.lender_stdcode + '-' + formValue.lender_landline; + lender_landline_no = formValue.lender_stdcode + '-' + formValue.lender_landline; } else { - concat_landline = null; + lender_landline_no = null; } } else { - concat_landline = null; + lender_landline_no = null; } if (formValue.applicant_stdcode != null || formValue.applicant_landline != null) { if (formValue.applicant_stdcode != '' && formValue.applicant_landline != '') { - concat_landline1 = formValue.applicant_stdcode + '-' + formValue.applicant_landline; + applicant_landline_no = formValue.applicant_stdcode + '-' + formValue.applicant_landline; } else { - concat_landline1 = null; + applicant_landline_no = null; } } else { - concat_landline1 = null; + applicant_landline_no = null; } let pd_details: any = { @@ -458,21 +476,23 @@ export class AddPdComponent implements OnInit, OnDestroy { "pd_branch_id": formValue.pd_branch_id, "pd_contact_person": formValue.lender_contact_person, "pd_contact_mobileno": formValue.lender_contact_mobile, - "pd_contact_landline": concat_landline, + "pd_contact_landline": lender_landline_no, "fk_product_id": formValue.fk_product_id, "fk_subproduct_id": formValue.fk_subproduct_id, "fk_pd_type": formValue.fk_pd_type, "fk_customer_segment": formValue.fk_customer_segment, "loan_amount": formValue.loan_amount, - "addressline1": formValue.addressline1.toUpperCase(), - "fk_city": formValue.fk_city, - "fk_state": formValue.fk_state, - "pincode": formValue.pincode, - "other_pincode": formValue.other_pincode, + "addressline1": formValue.addresses[0].addressline.toUpperCase(), + "fk_city": formValue.addresses[0].fk_city, + "fk_state": formValue.addresses[0].fk_state, + "pincode": formValue.addresses[0].pincode, + "other_pincode": formValue.addresses[0].other_pincode, "remarks": formValue.remarks, "pd_status": status, "fk_createdby": this._aws.getlocale(), }; + + var pd_applicant_details: any = []; if (formValue.applicant_name) { pd_applicant_details.push({ @@ -480,20 +500,35 @@ export class AddPdComponent implements OnInit, OnDestroy { "applicant_title_name": formValue.applicant_title_name, "company_name": formValue.company_name, "mobile_no": formValue.mobile_no, - "landline": concat_landline1, + "landline": applicant_landline_no, "applicant_type": 1, "relation": "", }); } - formValue.items.forEach((itemElement, itemIndex) => { + formValue.coapplicants.forEach((itemElement, itemIndex) => { + + let coapplicant_landline_no; + + if (itemElement.coapplicant_stdcode != null || itemElement.coapplicant_landline != null) { + if (itemElement.coapplicant_stdcode != '' && itemElement.coapplicant_landline != '') { + coapplicant_landline_no = formValue.coapplicant_stdcode + '-' + itemElement.applicant_landline; + } + else { + coapplicant_landline_no = null; + } + } + else { + coapplicant_landline_no = null; + } + let obj1 = { - "applicant_name": itemElement.coapplicantName, + "applicant_name":itemElement.coapplicant_name, "applicant_title_name": itemElement.applicant_title_name, "company_name": itemElement.company_name, - "mobile_no": itemElement.coapplicant_mobile_no, - "landline": itemElement.coapplicant_landline, - "applicant_type": 0, + "mobile_no":itemElement.coapplicant_mobile_no, + "landline": coapplicant_landline_no, + "applicant_type":0, "relation": "", } pd_applicant_details.push(obj1) @@ -519,12 +554,28 @@ export class AddPdComponent implements OnInit, OnDestroy { } pd_form.append("pd_document_titles", JSON.stringify(AllFilesObj)) + if (formValue.addtional_requirements.length > 0) { pd_form.append("addtional_requirements", JSON.stringify(formValue.addtional_requirements)) - } - // console.log('pd_form',pd_form); - // console.log('pd_details',pd_details); +return; + // formValue.addresses.forEach((addressElement, itemIndex) => { + // let addressobj = { + // "addressline": addressElement.addressline.toUpperCase(), + // "fk_city": addressElement.fk_city, + // "fk_state": addressElement.fk_state, + // "pincode": addressElement.pincode, + // "other_pincode": addressElement.other_pincode, + // } + + // }); + + if (formValue.addresses.length > 0) { + pd_form.append("addresses", JSON.stringify(formValue.addresses)) + } + + console.log('console.log(pd_form);',pd_form); + // return; this._pd.addPdDetails(pd_form).subscribe(result => { if (result.status == 200) { this.disableAfterSubmit = false; diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.html index cfa01dd06..68a5b5830 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.html @@ -172,11 +172,11 @@ {{applicant.applicant_name}} - + {{applicant.mobile_no}} - + {{applicant.landline}} diff --git a/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts b/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts index 18cdb2a84..7d3525aee 100755 --- a/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts +++ b/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts @@ -96,7 +96,9 @@ export class PdTrigerService { ) } - // get state and city details + /* get state and city details + This Api OnlyFor Bussiness info Details This Will Have 'Throughout state' option + */ getStateCityDetails(): Observable { return this._http.post(this.apiUrl + 'getListOfStatesCities','') .pipe(