diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-allocation/pd-allocation.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-allocation/pd-allocation.component.ts index a53acef..8e6231a 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-allocation/pd-allocation.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-allocation/pd-allocation.component.ts @@ -63,7 +63,7 @@ export class PdAllocationComponent implements OnInit { else { let updateData = { "pd_id":this.data.pd_id, - "fk_pd_allocated_to":allocateDetails.userid, + "vendor_pdofficer":allocateDetails.userid, "vendor_status":"ALLOCATED", } this._pd.updatePdOfficer(updateData).subscribe( diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/common-ques/common-ques.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/common-ques/common-ques.component.html new file mode 100644 index 0000000..17a49f6 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/common-ques/common-ques.component.html @@ -0,0 +1,977 @@ +

+
+ {{pdDetails.applicants_details[0].applicant_name}} {{pdDetails.lender_applicant_id ? '('+pdDetails.lender_applicant_id+')' : ''}}, {{pdDetails.customer_segment_abbr}} - + {{pdDetails.subproduct_abbr}}
+ FI Questions +
+
+ +
+

+ + +
+
+ + + + + General Section +
+
+
+ Applicants +
+
+ Is Person Met +
+
+ +
+
+
+ {{applicant.value.applicant_name}} +
+
+ + + + +
+

+
+
+
+ +
+ +
+ + + + Selfie of the Person Met +
+
+
+ +
+ + ID Proof of the person +
+
+
+
+
+ +
+
+ + + Name of Person Met + + Person Name required + + + + +
+
+
+ +
+ +
+ + + + Selfie of the Person Met + Required +
+
+
+ +
+ + ID Proof of the person +
+
+
+ + Designation + + + {{item.name.split('of')[0]}} + + Designation required + + + Relation + + + {{item.name}} + + Relation required + + + Relation to + + {{applicant.value.applicant_name}} + + Relation to required + +
+ + +
+ + +
+ +
+ + + + + Address Information + + + + + + + Address is Required + + + + + + + close + + + + Select + {{SL.name}} + + State is Required + + + + + + close + + + Select + {{CL.city_name}} + + City is Required + + + + + + + close + + + Select + {{PL.pincode}} + + Pincode is Required + +
+
+
+ +
+
+ +
+
+
+
+

+
+
+ + + Alternative Address Required + + + + + + close + + + + Select + {{SL.name}} + + + + + + + close + + + Select + {{CL.city_name}} + + + + + + + + close + + + Select + {{PL.pincode}} + + + + + + Pincode Required + + + + + + + Reason Required + + + +
+
+
+
+ + + + Select + {{m_addressType.address_type}} + + Address Type is Required + +
+ + + +
+ + + Select + {{m_locality.locality_name}} + + + + Locality is Required + + + + + + + + + Estimated area is Required + +
+ + + Select + {{uom.name}} + + UOM is Required + + + + + +
+ + +
+
+ + Approach to FI location + + Select + {{data.description}} + + Approach to pd location is Required + +
+
+
+ +
+ + + + Approach to pd location pic is Required +
+
+
+
+ + Comment on locality + + Select + {{data.rating | titlecase}} + + + Comment on locality is Required + +
+
+
+ + +
+ +
+ + + + + Business Information + +
+ +
+ + No. of employees sighted by FI officer during visit + + Required + + +
+
+ + Was the company name board sighted? + + Select + Yes + No + + Required + +
+
+
+ +
+ + +
+
+
+
+ + Business Documents sighted + + Select + Yes + No + + Required + +
+ +
+ +
+
+
+ + Choose the Documents + + Select + {{_doc.dis_name}} + + +
+
+
+ +
+ + +
+
+ +
+
+ +
+ +
+ +
+ + + + + + +
+ +
+

+ + Do You Want to Add Other Documents? + + Yes + No + + + + Required + + + +
+
+
+ + + +
+
+
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+ + + + + + +
+ +
+
+
+ Office Photographs +
+
+ +
+
+
+ +
+ Office Photograph {{i+1}} +
+
+
+ No Photographs Found
+ + + + +


+
+ + + + +
+ + + Was any business activities seen during visit? + + Select + Yes + No + + Required + +
+ + Choose + + {{item}} + + Please choose the value + + + + Please Specify + + +
+ + Is Business Asset Sighted + + Select + Yes + No + + Required + +
+ Business Asset Sighted Photographs +
+ +
+ +
+
+
+ +
+ Business Sight {{i+1}} +
+
+
+ No Photographs Found
+
+ + +
+
+ + + + +
+ + +
+ Stock Photograph

+ + Stock Photograph + + Yes + No + + Please choose the value + +
+
+ +
+
+
+ +
+ Stock Photograph {{i+1}} +
+
+
+ No Photographs Found
+
+ + +
+
+
+ + + + +
+ + + + +
+ + +
+ +
+ +
+ + Credit Manager Special Requests + + +
+ + + +
+
+ + +
+ + +
+
+ + + Neighbourhood Check Details (2 checks to be done) + + + + + Neighbour details {{n+1}} + + + +
+
+ + + + + + Neighbourhood Name is Required + + + + Select + Yes + No + + Please Choose + +
+
+
+ +
+ + + + Year is Required + + + + Month is Required + + +
+
+
+ + + + + {{app.name}} + + + pick atleast one organisation owner + + + + organisation owner is required + +
+ +


+
+
+ +
+ +
+ +
+ +
+
+
+ +
+
+

+ + Status of the check as per PD officer? + + {{item.name}} + + Required + + + Remarks + + Required + +
+ + +
+
+
+ + + Final Remarks + +
+

Comment on Footfall in the market where the B2C outlet is located…

+ + + Heavy Footfall ( lots of customers in the locality / marketplace ).
+ Medium Footfall ( Medium no of customers in the locality / marketplace ).
+ Low Footfall ( Few customers seen in the locality / marketplace ).
+ +

+
Required
+
+ + + Is there a competetion to the applicant's business in the location + + Select + Yes + No + + Required + + + + + + Required + + + + Any demolition activity seen in the locality by PD officer + + Select + Yes + No + + Required + + + + + + Required + + + Any sealing activity observed in the locality by PD officer + + Select + Yes + No + + Required + + + + + + Required + +
+ + +
+ +
+
+ + + Submit + + Final Status of visit + + + Positive + Negative + Could not verify + + Required + + + Comments + + +
+ + + + +
+
+
+
+
+ + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/common-ques/common-ques.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/common-ques/common-ques.component.scss new file mode 100644 index 0000000..022e7fe --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/common-ques/common-ques.component.scss @@ -0,0 +1,56 @@ +.paragraph_change { + color: #fff !important; + background-color: #e00201 !important; + } + + .mat-button, .mat-raised-button{ + background-color: #e24533; + color: white; + +} +.mat-stroked-button { + color: #e24533; + margin-right: 10px +} +.mat-button-div{ + float: right; + margin-top: 5%; + margin-bottom: 2%; +} +.mat-radio-group > .mat-radio-button,span { + margin: 10px; +} + + +::ng-deep .mat-slide-toggle.mat-checked:not(.mat-disabled) .mat-slide-toggle-thumb { + background-color: blue; /*replace with your color*/ +} + +::ng-deep .mat-slide-toggle.mat-checked:not(.mat-disabled) .mat-slide-toggle-bar { + background-color: skyblue; /*replace with your color*/ +} + +::ng-deep .mat-radio-button.mat-accent.mat-radio-checked .mat-radio-outer-circle{ + border-color:rgb(66, 134, 244); +} + +::ng-deep .mat-radio-button.mat-accent .mat-radio-inner-circle{ + color:rgb(66, 134, 244); + background-color:rgb(66, 134, 244) ; +} + +.mat-radio-button.mat-accent .mat-radio-ripple .mat-ripple-element { + background-color:rgb(255, 37, 37); +} +.mat-form-field { + // margin-top: 16px; + width: 100%; +} + + .whole_form { + @media(min-width:500px) { + margin-left: 5%; + margin-right: 5%; + } + } + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/common-ques/common-ques.component.spec.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/common-ques/common-ques.component.spec.ts new file mode 100644 index 0000000..4c7e88d --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/common-ques/common-ques.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CommonQuesComponent } from './common-ques.component'; + +describe('CommonQuesComponent', () => { + let component: CommonQuesComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CommonQuesComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CommonQuesComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/common-ques/common-ques.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/common-ques/common-ques.component.ts new file mode 100644 index 0000000..e4107c2 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/common-ques/common-ques.component.ts @@ -0,0 +1,1512 @@ +import { Component, OnInit, Inject, ViewChild } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { PdTrigerService } from 'app/personal-discussion/pd-service/pd-triger.service'; +import { MAT_DIALOG_DATA, MatStepper, MatDialogRef } from '@angular/material'; +import { NotifierService } from 'angular-notifier'; +import { AwsService } from 'app/AwsService/aws.service'; +import { FormBuilder, FormControl, Validators, FormArray } from '@angular/forms'; +import { ReplaySubject, Subject } from 'rxjs'; +import { DatePipe } from '@angular/common'; +import { takeUntil } from 'rxjs/operators'; + +@Component({ + selector: 'app-common-ques', + templateUrl: './common-ques.component.html', + styleUrls: ['./common-ques.component.scss'] +}) +export class CommonQuesComponent implements OnInit { + pdMasterData: any; + + stepperInfo= [{ + form_name:'General Section', + form_id:18, + stepper_index:0, + },{ + form_name:'Address Information', + form_id:5, + stepper_index:1 + },{ + form_name:'Business Information', + form_id:"BUSINESS_GROUP", + stepper_index:2 + }, + { + form_name:'Employer information', + form_id:"BUSINESS_GROUP", + stepper_index:2 + },{ + form_name:'Credit Manager Queries', + form_id:24, + stepper_index:3, + is_dynamic:true + },{ + form_name:'Neighbourhood Details', + form_id:19, + stepper_index:4, + is_dynamic:true + },{ + form_name:'Final Remarks', + form_id:20, + stepper_index:5, + is_dynamic:true + },{ + form_name:'Submit', + form_id:'COMMENTS', + stepper_index:5, + is_dynamic:true + },] + // public person_met_entered:FormControl= new FormControl('') + // public designation_entered:FormControl= new FormControl('') + // public relation_entered:FormControl= new FormControl('') + // public relation_to:FormControl= new FormControl('') + businessAssetLisany=[ + "Employees were seen at the visited premises", + "Customers/Clients were seen at the visited premises", + "Manufacturing activities were seen at the visited premises", + "Others (Please specify)" + ] + + + firstFormGroup: any; + secondFormGroup: any; + matExpanded:number = 0; + isDisplay:any = []; + isDisplay2:any = []; + isOrganisationOwner: any = []; + documents_list = [ + { + key:'shop_eat_act_cert', + dis_name:'Shop and Est Act Cert' + }, + { + key:'gst_Regn_cert', + dis_name:'GST Regn Cert' + }, + { + key:'export_import_cert', + dis_name:'Export / Import cert' + }, + { + key:'pf_regn', + dis_name:'PF Regn' + }, + { + key:'esic_regn', + dis_name:'ESIC Regn' + }, + { + key:'factory_cert', + dis_name:'Factory Cert' + }, + { + key:'practice_cert', + dis_name:'Cert of Practice' + }, + { + key:'eb_bill', + dis_name:'Electricity Bill' + }, + { + key:'rent_agreement', + dis_name:'Rent Agreement' + } + ] + neighbour_status_list:any=[{id:'',name:'Select'},{id:'Positive',name:'Positive'},{id:'Negative',name:'Negative'},{id:'Could not verify',name:'Could not verify'}] + pdlocation: any = []; + cmtlocality: any = []; + pdDetails: any = {pd_id:"1725"}; + // FormId: any; + existCompanyList: any = []; + mergeCompanyApplicant: any=[]; + applicants: any=[]; + currentDate: any; + pipe: any = new DatePipe('en-US'); + users: string; + spinner_access:boolean = false; + docs_tobe_collect: any = []; + creditManagerAnswer: any = null; + addressesList: any; + cityData: any=[]; + search: any; + pincodeData: any=[]; + cityDataValue: any=[]; + pincodeDataValue: any=[]; + alertnativeCityData: any=[]; + alertnativePincodeData: any=[]; + stateData: any =[]; + protected _onDestroy = new Subject(); + public filteredCity: ReplaySubject = new ReplaySubject(1); + public filteredState:ReplaySubject=new ReplaySubject(1) + addressTypes: any =[]; + locality: any =[]; + uomData: any =[]; + placeholderName: string = ''; + companyRelationshipList: any = []; + relationshipList: any = []; + customer_seg_abbr: any; + notifier: NotifierService; + get questions() { return this.firstFormGroup.get('questions');} + + employerform_pdinfo:any; + + @ViewChild('stepper') private myStepper: MatStepper; + + public designationFilterCtrl:FormControl = new FormControl(); + public relationFilterCtrl:FormControl = new FormControl(); + public filteredcompanyRelationshipList:ReplaySubject = new ReplaySubject(1); + public filteredrelationshipList:ReplaySubject = new ReplaySubject(1); + + constructor(private actRoute:ActivatedRoute,private quesService:PdTrigerService,private router:Router, + @Inject(MAT_DIALOG_DATA)public data,private _formBuilder:FormBuilder, + notifier:NotifierService,private _awsService:AwsService,private dialogRef:MatDialogRef) { + this.notifier=notifier + console.log("Hi") + // this.actRoute.queryParams.subscribe(params=>{ + // console.log("d",params,params['name']) + // }) + // this.pdMasterData= this._pd.pdQuestionMasterData + this.pdDetails = this.data + console.log(this.pdDetails); + this.docs_tobe_collect = this.data.docs_collected + // this.questionDetails=this.router.getCurrentNavigation().extras.state.questionDetails + // this.FormId=this.router.getCurrentNavigation().extras.state.FormId + this.applicants = this.pdDetails.applicants_details; + this.customer_seg_abbr = this.pdDetails.customer_segment_abbr + console.log("constr",this.pdDetails,this.docs_tobe_collect) + if(this.pdDetails.lender_short_name == 'CLIX' || this.pdDetails.lender_short_name == 'MWISE' || this.pdDetails.prod_catagory == 'LAEP') + { + let Index = this.stepperInfo.findIndex(vv=>vv.form_id == 'COMMENTS') + this.stepperInfo[Index].stepper_index+=1 + } + if(this.docs_tobe_collect == null || this.docs_tobe_collect == undefined || this.docs_tobe_collect.length == 0) { + // this.stepperInfo + for(let value of this.stepperInfo) { + if(value.is_dynamic) { + value.stepper_index-=1 + } + } + } + this.users = this._awsService.getlocale() + } + + filterList() { + this.relationFilterCtrl.valueChanges.pipe().subscribe(()=>{ + this.applyFilter(this.relationFilterCtrl.value,this.filteredrelationshipList,this.relationshipList,'name') + }) + this.designationFilterCtrl.valueChanges.pipe().subscribe(()=>{ + this.applyFilter(this.designationFilterCtrl.value,this.filteredcompanyRelationshipList,this.companyRelationshipList,'name') + }) + + } + applyFilter(filtered_text,filter_list,raw_list,obj_name) { + if (!raw_list) { + return; + } + // get the search keyword + let search = filtered_text; + if (!search) { + filter_list.next(raw_list.slice()); + return; + } else { + search = search.toLowerCase(); + } + // filter the banks + filter_list.next( + raw_list.filter(bank => bank[obj_name].toLowerCase().indexOf(search) > -1) + ); + } + +ngOnInit() { + // this.loadingProvider.dataLoader() + console.log("Current customer segment",this.customer_seg_abbr); + this.firstFormGroup = this._formBuilder.group({ + questions:this._formBuilder.array([this.addGeneralControls(),this.addAddressControls(), + this.addBusinessGroupControls(),this.addNeighbourhoodControls(),this.addFinalRemarksControls(), + this._formBuilder.group({ + final_comments:[''], + final_visit_status:['',Validators.compose([Validators.required])], + form_id:["COMMENTS"], + form_name:["Comments"] + }), this.addCreditManagerQueries()]) + + + }); + // console.log(this.firstFormGroup); + + setTimeout(()=>{ + +},5000); +this.addControl(); +console.log(this.firstFormGroup.value) +this.getMasters(); + this.currentDate = this.pipe.transform(new Date(), 'yyyy-MM-dd hh:mm:ss'); + this.addGeneralIndividualsGroup() + this.getFormDatas() + this.filterList() +} + +getInitialAddress(){ + // const control=this.pdQuestionAddress.controls['addresses'] + this.quesService.getAddressesDetails(this.pdDetails.pd_id).subscribe(res=>{ + if(res.dataStatus == true){ + this.addressesList = res.records.filter(item => item.isactive == 1 && item.assigned_pd == this.pdDetails.pd_id); + + if(this.addressesList.length > 0){ + this.addressesList.forEach((datas,index)=>{ + this.getCityAndPincodeDetails(datas.fk_state,index,1) + + let obj ={ + 'address': datas.addressline1, + 'address_type': '', + 'address_type_others': '', + 'state': datas.fk_state, + 'city': datas.fk_city, + 'pincode':datas.pincode_id, + 'pd_address_id': datas.pd_address_id, + 'pincode_others': datas.other_pincode, + 'locality': '', + 'locality_others': '', + // 'locality_mixuse':'', + 'pd_location': '', + 'comment_locality': '', + 'estimated_area': '', + 'uom': '', + 'uom_others': '' + } + + // control.push(this.initAddress(obj)) + this.getQuestionControl().at(1).patchValue(obj) + console.log(this.firstFormGroup.value) + }) + } + else{ + // control.push(this.initAddress('')) + } + } + else{ + // control.push(this.initAddress('')) + } + }) +} + +getCityAndPincodeDetails(stateID: string,i,flag) { + + //this.pdQuestionAddress.controls['addresses']['controls'].controls + this.quesService.getStateWiseCities(stateID).subscribe(data => { + if (data.status == 200) { + this.cityData[i] = data.records.cities; + this.search=this.cityData[i] + this.pincodeData[i] = data.records.pincode; + + //this.filteredCity.next(this.cityData[i].slice()) + if(flag== 1){ + this.cityDataValue[i]=this.cityData[i].slice() + // this.pincodeData[i] = data.records.pincode; + this.pincodeDataValue[i]=this.pincodeData[i].slice() + } + else if(flag == 2){ + this.alertnativeCityData[i]=this.cityData[i].slice() + this.alertnativePincodeData[i]=this.pincodeData[i].slice() + } + } + //FOR PINCODE FREE TEXT + // let pin + // if(pincode != ''){ + // if(pincode != 1){ + // this.pincodeValue[i]=this.pincodeData[i].filter(res=>res.pincode_id == pincode).map(val=>val.pincode)[0] + // //this.pincodeValue[i]=[].concat.apply([],this.pincodeValue[i]) + + + // } + // } + }); +} + + +getMasters() { + this.quesService.getAllMasterDatas('PDLOCATIONAPPROACH').subscribe(res=> + { + this.pdlocation = res; + if(this.pdlocation.dataStatus == true) + { + this.pdlocation = this.pdlocation.records.filter(loca=>loca.isactive ==1); + } + }) + this.quesService.getAllMasterDatas('COMMENTSONLOCALITY').subscribe(res=> + { + this.cmtlocality = res; + if(this.cmtlocality.dataStatus ==true) + { + this.cmtlocality = this.cmtlocality.records.filter(loc=>loc.isactive ==1); + } + }); + this.quesService.getCompaniesListsForBusiness(this.pdDetails.pd_id).subscribe(res=>{ + if(res.dataStatus==true){ + this.existCompanyList=res.records.filter(val=>val.is_active == true) + console.log(this.existCompanyList) + } + let modifyCompanyList:any=[] + if(this.existCompanyList.length>0){ + modifyCompanyList=this.existCompanyList.map(element=>{ + return {id:element.company_order_id.toString(),name:element.company_name,group_id:1}; + }); + this.mergeCompanyApplicant.push({groupName: 'COMPANIES', groupValues: modifyCompanyList }) + + } + let modifyApplicantList:any=[] + if(this.applicants.length>0){ + modifyApplicantList=this.applicants.map(element=>{ + return {id:element.pd_co_applicant_id,name:element.applicant_name,group_id:2}; + }) + this.mergeCompanyApplicant.push({groupName:'APPLICANTS',groupValues:modifyApplicantList}) + + } + console.log("company&Applicant",this.mergeCompanyApplicant) + }) + this.quesService.getAllMasterDatas('STATE').subscribe(res=>{ + this.stateData=res['records'].filter(val=>val.isactive == 1); + this.filteredState.next(this.stateData.slice()) + + }) + this.quesService.getAllMasterDatas('ADDRESSTYPE').subscribe(res=> + { + if(res['dataStatus']==true){ + this.addressTypes = res['records'].filter(add=>add.isactive==1); + // this.cacheObservable.register('addressType',this.addressTypes).subscribe(res=>{ + // this.data$=res.get$ + // }) + } + // this.cacheObservable.loadFromObservable() + }) + this.quesService.getAllMasterDatas('LOCALITY').subscribe(res=> + { + if(res['dataStatus']==true) + { + this.locality = res['records'].filter(loc=>loc.isactive==1); + } + }) + this.quesService.getAllMasterDatas('UOM').subscribe(res=>{ + this.uomData=res['records'].filter(val=>val.isactive == 1 && val.is_land_uom != 0) + }) + this.quesService.getAllMasterDatas('COMPANYRELATIONSHIPS').subscribe(rr=>{ + if(rr['dataStatus']) { + this.companyRelationshipList = rr['records'].filter(vv=>vv.isactive == '1'); + this.filteredcompanyRelationshipList.next(this.companyRelationshipList.slice()) + let temp = [{master_name:'COMPANYRELATIONSHIPS',master_data:this.companyRelationshipList}] + this.employerform_pdinfo = this.pdDetails + this.employerform_pdinfo.masterData= temp; + } + + }) + this.quesService.getAllMasterDatas('RELATIONSHIPS').subscribe(rr=>{ + this.relationshipList = rr['records'].filter(vv=>vv.isactive == '1'); + this.filteredrelationshipList.next(this.relationshipList.slice()) + }) +} + +getFormDatas() { + let params = {'parent_pdid':this.pdDetails.parent_pd_id,'pd_id':this.pdDetails.pd_id,'pd_form_id':"25"} + this.quesService.getPDFormDetailsWithID(params).subscribe(result=>{ + if(result && result['dataStatus']) { + this.generateGroupControls(result['records'].questions) + } + else { + this.getInitialAddress(); + this.getBusinessDocumentsSighted() + } + // this.loadingProvider.dismissLoader() + },err=>{ + console.log("getPDFormDetails Error",err) + // this.loadingProvider.dismissLoader(); + this.notifier.notify("Network Error",'danger'); + }) + // this.quesService.getAllQuesSample().subscribe((result:any)=> { + // console.log("Result",result) + // if(result) { + // // this.generateGroupControls(result.questions) + // } + // }) +} + +generateGroupControls(datas) { + if(datas && datas.length > 0) { + // FOR ADDRESS FORM + let address_index = datas.findIndex(val=>val.form_id == "5") + if(address_index && datas[address_index]) { + if(datas[address_index].hasOwnProperty('state') && datas[address_index].state) { + this.getCityAndPincodeDetails(datas[address_index].state,0,1); + if(datas[address_index].hasOwnProperty('alternative_addresses') && datas[address_index].alternative_addresses && datas[address_index].alternative_addresses[0].alternative_state) { + this.getCityAndPincodeDetails(datas[address_index].alternative_addresses[0].alternative_state,0,2); + } + } + if(datas[address_index].hasOwnProperty('address_type') && datas[address_index].address_type) { + if(datas[address_index].address_type != 1) { + let selectedAddressType = this.addressTypes.filter(element => element.address_type_id == datas[address_index].address_type)[0]; + if(selectedAddressType != undefined && selectedAddressType.hasOwnProperty('address_type')){ + this.selectedAddressType(selectedAddressType.address_type); + } + } + else { + this.selectedAddressType(datas[address_index].address_type_others); + } + } + + + + } + // FOR BUSINESS GROUP + let business_group_index = datas.findIndex(val=>val.form_id == "BUSINESS_GROUP") + console.log(business_group_index); + if(business_group_index) { + if(datas[business_group_index].hasOwnProperty('business_group')) { + datas[business_group_index].business_group.forEach(group_obj=>{ + // For Documents Sighted + if(group_obj.form_id == "13" && group_obj.hasOwnProperty('documents_sighted') && group_obj.documents_sighted == 'yes') { + if(group_obj.documents_info) { + group_obj.documents_info.forEach(doc=>{ + this.addDocumentsGroup() + }) + } + } + if(group_obj.form_id == "13" && group_obj.hasOwnProperty('office_photographs') && group_obj.office_photographs) { + group_obj.office_photographs.forEach(()=>{ + this.addMoreBusinessOfficeImage() + }) + } + // FOR BUSINESS ASSET SIGHT IMAGE HANDLING + if(group_obj.form_id == "22" && group_obj.hasOwnProperty('business_sight_image') && group_obj.business_sight_image) { + group_obj.business_sight_image.forEach(()=>{ + this.addMoreBusinessAssetSightImage() + }) + } + // For Other Documents images + if(group_obj.form_id == "13" && group_obj.hasOwnProperty('other_documents') && group_obj.other_documents == 'yes') { + if(group_obj.other_documents_info) { + group_obj.other_documents_info.forEach(doc=>{ + this.addOtherDocumentsGroup() + }) + } + } + // FOR STOCK IMAGES + if(group_obj.form_id == "11" && group_obj.hasOwnProperty('images') && group_obj.images) { + group_obj.images.forEach(()=>{ + this.addMoreStockImage() + }) + } + }) + } + } + // FOR CREDIT MANAGER + let crdmngr_index = datas.findIndex(val=>val.form_id == "24") + console.log(business_group_index); + if(crdmngr_index) { + // if(group_obj.form_id == "24" && group_obj.hasOwnProperty('docs_to_be_sighted') && group_obj.docs_to_be_sighted + // && this.docs_tobe_collect != null && this.docs_tobe_collect != undefined && this.docs_tobe_collect.length > 0) { + this.creditManagerAnswer = datas[crdmngr_index] + // } + } + // FOR NEIGHBOURHOOD GROUP GENERATION + let neighbour_group_index = datas.findIndex(val=>val.form_id == "19") + console.log(business_group_index); + if(neighbour_group_index) { + this.toggleVisibility(datas[neighbour_group_index].neighbourhood_list[0].did_not_know_the_business_operation,0,1) + this.toggleVisibility(datas[neighbour_group_index].neighbourhood_list[0].did_not_know_the_owner,0,2) + for(let i=1; i < datas[neighbour_group_index].neighbourhood_list.length ; i++) { + // datas[neighbour_group_index].neighbourhood_list.forEach(()=>{ + let neighbour_obj= datas[neighbour_group_index].neighbourhood_list[i] + this.toggleVisibility(neighbour_obj.did_not_know_the_business_operation,i,1) + this.toggleVisibility(neighbour_obj.did_not_know_the_owner,i,2) + // }) + this.addNeighbourhoodGroup() + } + } + this.firstFormGroup.get('questions').patchValue(datas); + } +} +getBusinessDocumentsSighted() { + this.quesService.getBusinessDocsToVendorForm(this.pdDetails.pd_id).subscribe(res=>{ + if(res['dataStatus']) { + let data= res['records']; + if(data && data.length > 0) { + let docs_value_arr:any=[] + data.forEach(rr=>{ + this.addDocumentsGroup() + docs_value_arr.push({document_name:rr}); + }) + + let temp:any = {documents_sighted: "yes",documents_info:docs_value_arr} + console.log("Current docs sighted value",docs_value_arr,temp,this.getBusinessInfoControls().at(0)) + this.getBusinessInfoControls().at(0).patchValue(temp) + } + } + }) +} + +createControl() { + return this._formBuilder.group({ + // firstCtrl:['', Validators.required], + // secondCtrl:['', Validators.required] + }) +} +action() { + let merged:object = {} + // for(let val of this.firstFormGroup.value.formArray) { + // console.log("dsdf",val); + // if(val) + // { + // Object.assign(merged,val) + // } + // } + // console.log("das",merged) + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // console.log(business_group_ctrl); + let stockCtrl = business_group_ctrl.at(2).get('images') as FormArray + // console.log("stock",stockCtrl); + console.log(this.firstFormGroup.value,JSON.stringify(this.firstFormGroup.value)); + let neighbourCtrl = formArray.at(3).get('neighbourhood_list') as FormArray + // console.log(neighbourCtrl); + return stockCtrl.controls +} +addControl() { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + // formArray.insert(23,this.createControl()); +} + +// START OF FORM CONTROL NAME GROUPS +addGeneralControls() { + return this._formBuilder.group({ + individuals:this._formBuilder.array([]), + // is_person_met_id_proof:[''], + // is_person_met_pic:[''], + // is_person_met:[false], + form_id:['18'], + form_name:["General Info"], + // general_remark:[''], + person_met_entered:[''], + designation_entered:[''], + relation_entered:[''], + relation_to:[''], + person_met_entered_pic:[''], + person_met_entered_id_proof:[''] + }) +} +addGeneralIndividualControls(applicant_obj) { + return this._formBuilder.group({ + is_person_met_id_proof:[''], + is_person_met_pic:[''], + is_person_met:[false], + pd_co_applicant_id:[applicant_obj.pd_co_applicant_id], + applicant_name:[applicant_obj.applicant_name] + }) +} +addAddressControls() { + return this._formBuilder.group({ + address:['',Validators.compose([Validators.required])], + state:['',Validators.compose([Validators.required])], + stateSearch:[''], + city:['',Validators.compose([Validators.required])], + citySearch:[''], + pincode:['',Validators.compose([Validators.required])], + pinSearch:[''], + alternative_addresses:this._formBuilder.array([ + this._formBuilder.group({ + alternative_address:[''], + alternative_state:[''], + stateSearch:[''], + alternative_city:[''], + citySearch:[''], + alternative_pincode:[''], + pinSearch:[''], + alternative_pincode_others:[''], + reason_for_alternative_address:[''] + }) + ]), + address_type:['',Validators.compose([Validators.required])], + address_type_others:[''], + locality:['',Validators.compose([Validators.required])], + locality_others:[''], + estimated_area:['',Validators.compose([Validators.required])], + uom:['',Validators.compose([Validators.required])], + uom_others:[''], + is_pd_done_on_initiated_address:[true], + pd_location:['',Validators.compose([Validators.required])], + pd_location_pic:[''], + comment_locality:['',Validators.compose([Validators.required])], + form_id:['5'], + form_name:["Address Info"], + }) +} +addBusinessGroupControls() { + if(this.customer_seg_abbr != 'SAL') { + return this._formBuilder.group({ + business_group:this._formBuilder.array([ + this.addBusinessInfoControls(),this.addBusinessAssetControls(),this.addStockControls(), + ]), + form_id:["BUSINESS_GROUP"], + form_name:["Business Group Info"] + }) +} +else { + return this._formBuilder.group({ + form_id:["BUSINESS_GROUP"], + form_name:["Business Group Info"] + }) +} +} +addStockControls() { + return this._formBuilder.group({ + form_name:"Stock Info", + form_id:["11"], + is_stock_photo:['',Validators.required], + images:this._formBuilder.array([ + // this._formBuilder.group({ + // image:["https://lh3.googleusercontent.com/proxy/euOnni6JKoCJKwXq9Hq8c6fkRaxI5SYQVsHUwx_w_Wt_9zGXsABxnFsjRv7_E3Xer35VR1oalGBRKWdlwQPMo9SoDqOrmx9h7zqmAXMG37rcrpaU_jPXMXAdffKjB0M_zy3yQNJRpOKvqUlx2JmvB68r8cDCGbVUQvW8Zk2yoR4I23i4ZM7U"] + // }), + // this._formBuilder.group({ + // image:["https://lh3.googleusercontent.com/proxy/euOnni6JKoCJKwXq9Hq8c6fkRaxI5SYQVsHUwx_w_Wt_9zGXsABxnFsjRv7_E3Xer35VR1oalGBRKWdlwQPMo9SoDqOrmx9h7zqmAXMG37rcrpaU_jPXMXAdffKjB0M_zy3yQNJRpOKvqUlx2JmvB68r8cDCGbVUQvW8Zk2yoR4I23i4ZM7U"] + // }) + ]) + }) +} +addStockImageControl() { + return this._formBuilder.group({ + image:[''] + }) +} +addCreditManagerQueries() { + return this._formBuilder.group({ + form_name:"Credit Manager Queries", + form_id:["24"], + docs_to_be_sighted:this._formBuilder.array([]) + }) +} +addEmployerInfoForm() { + return this._formBuilder.group({ + form_name:"Employer Information", + form_id:["12"], + // docs_to_be_sighted:this._formBuilder.array([]) + }) +} +addBusinessInfoControls() { + return this._formBuilder.group({ + officer_total:['',Validators.compose([Validators.required])], + was_the_company_name_board_sighted:['',Validators.compose([Validators.required])], + name_board_sighted_pic:[''], + documents_sighted:['',Validators.compose([Validators.required])], + documents_info:this._formBuilder.array([]), + other_documents:['',Validators.compose([Validators.required])], + other_documents_info:this._formBuilder.array([]), + office_photographs:this._formBuilder.array([]), + form_name:["Business Info"], + form_id:["13"] + }) +} +addBusinessInfoDocsControls() { + return this._formBuilder.group({ + document_name:['',Validators.compose([Validators.required])], + document_image:[''] + }) +} +addBusinessInfoOtherDocsControls() { + return this._formBuilder.group({ + document:[''], + document_pic:[''] + }) +} +addBusinessAssetControls() { + return this._formBuilder.group({ + business_is_pd_visited:['',Validators.compose([Validators.required])], + business_is_pd_visited_pic:[''], + business_is_pd_visited_yes:[''], + specify_pd_visited:[''], + business_asset_sight:['',Validators.compose([Validators.required])], + business_sight_image:this._formBuilder.array([]), + // business_pd_visited_remark:[''], + form_name:["Business Assets"], + form_id:["22"] + }) +} + +addNeighbourhoodControls() { + return this._formBuilder.group({ + form_id:["19"], + form_name:["Neighbourhood Details"], + neighbourhood_list:this._formBuilder.array([this.addNeighbourListControls()]), + neighbourhood_status:[''], + neighbour_reference_remark:[''] + }) +} +addNeighbourListControls() { + return this._formBuilder.group({ + neighbourhood_name:[''], + do_know:[''], + did_not_know_the_business_operation:[''], + how_long_do_know_in_year:[''], + how_long_do_know_in_month:[''], + organisation_owner:[''], + other_organisation_owner:[''], + did_not_know_the_owner:[''], + }) +} + +addFinalRemarksControls() { + return this._formBuilder.group({ + form_name:["Final Remarks"], + form_id:["20"], + outlet_location:[''], + is_competition:[''], + demolition_activity:[''], + sealing_activity:[''], + appx_outlet_or_stores:[''], + comment_of_demolition_activity:[''], + comment_of_sealing_activity:[''], + +}) +} +// END OF FORM CONTROL NAME GROUPS + +// START OF GETTING PARTICULAR FORM CONTROLS +getStockControl() { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // console.log(business_group_ctrl); + let stockCtrl = business_group_ctrl.at(2).get('images') as FormArray + // console.log("stock",stockCtrl); + // console.log(this.firstFormGroup.value); + return stockCtrl.controls +} +getBusinessInfoOfficePhotControls() { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // console.log(business_group_ctrl); + let stockCtrl = business_group_ctrl.at(0).get('office_photographs') as FormArray + // console.log("stock",stockCtrl); + // console.log(this.firstFormGroup.value); + return stockCtrl.controls +} +getBusinessAssetSightImage() { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // console.log(business_group_ctrl); + let stockCtrl = business_group_ctrl.at(1).get('business_sight_image') as FormArray + // console.log("stock",stockCtrl); + // console.log(this.firstFormGroup.value); + return stockCtrl.controls +} +getBusinessInfoDocsControl() { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // console.log(business_group_ctrl); + let docsCtrl = business_group_ctrl.at(0).get('documents_info') as FormArray + // console.log("stock",docsCtrl); + // console.log(this.firstFormGroup.value); + return docsCtrl.controls +} +getBusinessInfoOtherDocsControl() { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // console.log(business_group_ctrl); + let docsCtrl = business_group_ctrl.at(0).get('other_documents_info') as FormArray + // console.log("stock",docsCtrl); + // console.log(this.firstFormGroup.value); + return docsCtrl.controls +} +getBusinessInfoControls() { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // console.log(business_group_ctrl); + return business_group_ctrl +} +getNeibhourControl() { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let neighbourCtrl = formArray.at(3).get('neighbourhood_list') as FormArray + // console.log(neighbourCtrl); + return neighbourCtrl.controls +} +getQuestionControl() { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + return formArray +} +// END OF GETTING PARTICULAR FORM CONTROLS + +//START OF ADD OR REMOVE MORE FORMS OR IMAGES +addMoreStockImage(form_id?) { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // console.log(business_group_ctrl); + let stockCtrl = business_group_ctrl.at(2).get('images') as FormArray + // console.log("stock",stockCtrl); + // stockCtrl.push(this.addStockImageControl()) + if(form_id) { + // this.capturePic(stockCtrl,'stock_image ',form_id) + } + else { + stockCtrl.push(this.addStockImageControl()) + // stockCtrl = stockCtrl.at(stockCtrl.length-1)['controls'].image + } + // console.log(this.firstFormGroup.value); +} +addMoreBusinessOfficeImage(form_id?) { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // console.log(business_group_ctrl); + let officeControl = business_group_ctrl.at(0).get('office_photographs') as FormArray + // console.log("stock",stockCtrl); + // stockCtrl.push(this.addStockImageControl()) + if(form_id) { + // this.capturePic(officeControl,'office_photograph ',form_id) + } + else { + officeControl.push(this.addStockImageControl()) + // stockCtrl = stockCtrl.at(stockCtrl.length-1)['controls'].image + } + // console.log(this.firstFormGroup.value); +} +addMoreBusinessAssetSightImage(form_id?) { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // console.log(business_group_ctrl); + let stockCtrl = business_group_ctrl.at(1).get('business_sight_image') as FormArray + // console.log("stock",stockCtrl); + // stockCtrl.push(this.addStockImageControl()) + if(form_id) { + // this.capturePic(stockCtrl,'business_sight_image ',form_id) + } + else { + stockCtrl.push(this.addStockImageControl()) + // stockCtrl = stockCtrl.at(stockCtrl.length-1)['controls'].image + } + // console.log(this.firstFormGroup.value); +} + +addGeneralIndividualsGroup() { + let formArray = this.firstFormGroup.get('questions') as FormArray; + let individualCtrl = formArray.at(0).get('individuals') as FormArray + if(this.applicants.length > 0) + { + this.applicants.forEach(applicant_obj=>{ + individualCtrl.push(this.addGeneralIndividualControls(applicant_obj)) + }) + } +} + +addNeighbourhoodGroup() { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let neighbourCtrl = formArray.at(3).get('neighbourhood_list') as FormArray + // console.log(neighbourCtrl); + neighbourCtrl.push(this.addNeighbourListControls()) + this.matExpanded= neighbourCtrl.length-1 +} + +removeneighbourhoodGroup(index) { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let neighbourCtrl = formArray.at(3).get('neighbourhood_list') as FormArray + // console.log(neighbourCtrl); + if(neighbourCtrl.length==1) + { + neighbourCtrl.reset(); + }else{ + neighbourCtrl.removeAt(index); + this.matExpanded = neighbourCtrl.length-1 + } +} +addDocumentsGroup( ) { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // console.log(business_group_ctrl); + let docsCtrl = business_group_ctrl.at(0).get('documents_info') as FormArray + docsCtrl.push(this.addBusinessInfoDocsControls()) +} + +removeDocumentsGroup(index) { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // console.log(business_group_ctrl); + let docsCtrl = business_group_ctrl.at(0).get('documents_info') as FormArray + if(docsCtrl.length==1) + { + docsCtrl.reset(); + }else{ + docsCtrl.removeAt(index); + } +} +addOtherDocumentsGroup( ) { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // console.log(business_group_ctrl); + let docsCtrl = business_group_ctrl.at(0).get('other_documents_info') as FormArray + docsCtrl.push(this.addBusinessInfoOtherDocsControls()) +} + +removeOtherDocumentsGroup(index) { + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // console.log(business_group_ctrl); + let docsCtrl = business_group_ctrl.at(0).get('other_documents_info') as FormArray + if(docsCtrl.length==1) + { + docsCtrl.reset(); + }else{ + docsCtrl.removeAt(index); + } +} +//END OF ADD OR REMOVE MORE FORMS OR IMAGES + +toggleVisibility(e,index,flag){ + let val + + if(flag == 1){ + this.isDisplay[index] = e; + } + else if(flag==2){ + this.isDisplay2[index] = e; + } +} +getOtherOrganisationOwner(value,i) { + //console.log('value',value,'I',i); + let formArray = this.firstFormGroup.get('questions') as FormArray; + // console.log(formArray); + let Ctrls = formArray.at(3).get('neighbourhood_list') as FormArray + // console.log(Ctrls); + //console.log('ParCtrls',Ctrls); +let ChdCtrls:any = Ctrls.controls[i]; + // console.log('ChdCtrls',ChdCtrls); + // return; + + +let Avaliablity = 1; +// console.log('val',value); +if(value.length>0){ + value.forEach(option => { + if(option.id == 0 && option.group_id == 2){ + Avaliablity = option.id; + } + }); +} +if(Avaliablity == 0){ +// console.log('if Avaliablity',Avaliablity); + + ChdCtrls.controls.other_organisation_owner.setValidators([Validators.required]); + this.isOrganisationOwner[i] = true; +}else if(Avaliablity == 1){ +// console.log('else Avaliablity',Avaliablity); +// console.log('esle this.isOrganisationOwner[ParInx]',this.isOrganisationOwner[i]); + ChdCtrls.controls.other_organisation_owner.setValue(''); + ChdCtrls.controls.other_organisation_owner.clearValidators(); + this.isOrganisationOwner[i] = false; +// console.log('else this.isOrganisationOwner[ParInx]',this.isOrganisationOwner[i]); +} + +ChdCtrls.controls.other_organisation_owner.updateValueAndValidity(); +} + +// capturePic(controls,img_name?:String,form_id?) { +// console.clear(); +// console.log(controls) +// // return; +// // controls.setValue("pic"); + +// // this.cameraProvider.getpicture().then(res => { +// this.cameraProvider.showImageDialog().then((res:any)=>{ +// console.log("g",res) +// if (res != 'error') { +// let geoCoordinates = localStorage.getItem('current_coordinates') +// // this.cons.getGeoTag().then(geoCoordinates=>{ +// this.cameraProvider.addWatermarks(res).then(watermarkedImage => { +// console.log("image name",img_name,img_name === 'office_photograph ') +// if(img_name == 'stock_image ' || img_name == 'office_photograph ' || img_name == 'business_sight_image ') { +// console.log("Before") +// controls.push(this.addStockImageControl()) +// console.log("after") +// img_name = img_name+String(controls.length) +// controls = controls.at(controls.length-1)['controls'].image +// } +// console.log("controls",controls); +// controls.setValue(watermarkedImage) +// let bucket: any = [] +// bucket.push({ 'image': watermarkedImage, 'Name': img_name, 'link': geoCoordinates }); +// let records: any = { +// 'pd_id': this.pdDetails.pd_id, +// 'formid': form_id, +// 'images': bucket, +// 'company_id': null, +// } +// // For Business Groups +// if(form_id == '11' || form_id == '13' || form_id == '22') { +// records.company_id = '1' +// } +// console.log("params savePDImage", records) +// this.quesService.savePDImages(records).subscribe(result => { +// if(result['dataStatus']) { +// controls.setValue(result['uri']) +// } +// else { +// console.log(result); +// controls.setValue("") +// this.toastProvider.pdTriggerappmessage("Something went wrong!!",'warning'); +// } +// },err=>{ +// controls.setValue("") +// console.log(err) +// this.toastProvider.pdTriggerappmessage("Network Error","danger") +// }) +// }) +// } +// }) +// } +compareObjects(o1: any, o2: any) { + if(o1.id == o2.id && o1.group_id == o2.group_id) + return true; + else return false +} + +ConvertMonthintoYear(itemrow,e,flag){ + if(flag == 2){ + + let year = itemrow.controls.year_relation_applicant.value; + let converted_month : number = e%12; + let converted_year : number = e/12; + itemrow.controls.year_relation_applicant.setValue(+year + +Math.floor(converted_year)); + itemrow.controls.months_relation_applicant.setValue(Math.floor(converted_month)); + } + else if(flag == 1){ + + let year = itemrow.controls.how_long_do_know_in_year.value; + let converted_month : number = e%12; + let converted_year : number = e/12; + itemrow.controls.how_long_do_know_in_year.setValue(+year + +Math.floor(converted_year)); + itemrow.controls.how_long_do_know_in_month.setValue(Math.floor(converted_month)); + } +} +onDocsSightedChange(value,flag) { + // 1 - Documents sighted + // 2 - Other Documents + + let formArrayName = 'documents_info' + if(flag != 1) { + formArrayName = 'other_documents_info' + } + if(value == 'yes') { + if(flag == 1) { + this.addDocumentsGroup() + } + else { + this.addOtherDocumentsGroup(); + formArrayName = 'other_documents_info' + } + } + else { + + let formArray = this.firstFormGroup.get('questions') as FormArray; + let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + let docsCtrl = business_group_ctrl.at(0).get(formArrayName) as FormArray + while(docsCtrl.length !== 0) { + docsCtrl.removeAt(0) + } + } +} + +// saveApplicantInfo(applicant_obj,image_key) { +// console.log(applicant_obj); +// this.cameraProvider.showImageDialog().then((res:any)=>{ +// console.log("g",res) +// if (res != 'error') { +// let geoCoordinates = localStorage.getItem('current_coordinates') +// // this.cons.getGeoTag().then(geoCoordinates=>{ +// this.cameraProvider.addWatermarks(res).then(watermarkedImage => { +// applicant_obj.controls[image_key].setValue(watermarkedImage); +// let params = { +// "pd_co_applicant_id":applicant_obj.value.pd_co_applicant_id, +// "applicant_name":applicant_obj.value.applicant_name, +// "is_person_met":applicant_obj.value.is_person_met, +// "fk_pd_id":this.pdDetails.pd_id, +// "link":geoCoordinates +// } +// params[image_key] = applicant_obj.value[image_key] + +// this.quesService.saveApplicantImgFromVendorForm(params).subscribe(result=>{ +// if(result['dataStatus']) { +// applicant_obj.controls[image_key].setValue(result['uri']); +// } +// else { +// applicant_obj.controls[image_key].setValue(""); +// console.log(result); +// this.toastProvider.pdTriggerappmessage("Something went wrong!!",'warning'); +// } +// },err=>{ +// applicant_obj.controls[image_key].setValue(""); +// console.log(err) +// this.toastProvider.pdTriggerappmessage("Network Error","danger") +// }) +// }) +// } +// }) +// } +public findInvalidControls() { + const invalid = []; + let msg='' + let formArray = this.firstFormGroup.get('questions') as FormArray; + console.log(formArray); + for( const group of formArray['controls']) { + if(group.invalid) { + console.log(group,group.value.form_name); + // debugger; + msg= "Questions are not filled up in "+group.value.form_name + let index = this.stepperInfo.findIndex(vv=>vv.form_id == group.value.form_id); + console.log("Index",index); + if(index != -1) { + msg = "Questions are not filled up in "+this.stepperInfo[index].form_name + this.myStepper.selectedIndex = this.stepperInfo[index].stepper_index + } + for (const name in group['controls']) { + if (group['controls'][name].invalid) { + invalid.push(name); + let invalidFields = [].slice.call(document.getElementsByClassName('ng-invalid')); + let firstInvalidField; + for(let val in invalidFields){ + if( invalidFields[val].nodeName == 'MAT-FORM-FIELD' || invalidFields[val].nodeName == 'MAT-SELECT' || invalidFields[val].nodeName == 'TEXTAREA' ){ //INPUT FOR INPUT FIELD + firstInvalidField=invalidFields[val] + break; + } + } + if(firstInvalidField != undefined){ + firstInvalidField.scrollIntoView({behavior: "smooth", block: "end", inline: "nearest"}) + // this.myStepper.selectedIndex = 0; + + } + + console.log("kkdd",group['controls'][name],firstInvalidField) + + // if(typeof(group['controls'][name].value) == 'string') { + // return name+' field is not ' + // } + break + } + } + break; + } + } + // let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // const controls = this.getQuestionControl().at(1)['controls'] + // for (const name in controls) { + // if (controls[name].invalid) { + // invalid.push(name); + // } + // } + return msg; +} +// public findInvalidControls() { +// const controls = this.quesAnsForm.get('questions')['controls']; +// console.log(controls) +// for (const name in controls) { +// if (controls[name].invalid) { +// let invalidFields = [].slice.call(document.getElementsByClassName('ng-invalid')); +// let firstInvalidField; +// for(let val in invalidFields){ +// if( invalidFields[val].nodeName == 'MAT-FORM-FIELD'){ //INPUT FOR INPUT FIELD +// firstInvalidField=invalidFields[val] +// break; +// } +// } +// if(firstInvalidField != undefined){ +// firstInvalidField.scrollIntoView(true) +// } +// break; +// } +// } +// // return invalid; +// } +onSubmit(flag?) { + if(this.spinner_access) { + this.notifier.notify('warning',"Form processing please wait..."); + return; + } + if(this.firstFormGroup.invalid && flag != 'go_back') { + console.log('form value',this.firstFormGroup.getRawValue()) + let invalidMsg = "Please Fill all the required fields and capture the image" + let tempMsg = this.findInvalidControls() + if(tempMsg != '') { + invalidMsg =tempMsg + } + this.notifier.notify('info',invalidMsg); + return + } + // return; + this.spinner_access = true; + let records= this.firstFormGroup.getRawValue() + console.log(records); + records.pdid = this.pdDetails.pd_id; + records.formid = "25"; + records.fk_createdby = this.users; + this.quesService.savePDFormDetailsWithID(records).subscribe(result=>{ + if(result['dataStatus']) { + if(flag != 'go_back') { + this.notifier.notify('success',"Saved Successfully...",); + } + this.firstFormGroup.markAsPristine(); + this.firstFormGroup.markAsUntouched(); + if(flag != 'go_back') { + setTimeout(()=>{ + this.dialogRef.close() + },3000) + } + } + else { + this.notifier.notify('warning',"Something went wrong"); + } + this.spinner_access = false + },err=>{ + console.log("Error in savePDFormDetails",err); + this.notifier.notify('danger',"Network Error"); + this.spinner_access = false + }) +} + +// FOR CHECKING THE UNSAVED CHANGES + +canDeactivate(){ + // this.timer.unsubscribe(); + console.log(this.firstFormGroup.dirty) + if(this.firstFormGroup.dirty){ + this.onSubmit('go_back'); +// return this.constant.chekAlertOnLeave().then(res=>{ +// console.log(res) +// return res +// }) + return true; +} +else{ + return true +} +} +countRowsForTextarea(text){ + + + + if(text !='' && text != undefined){ + if(text.length%100 > 5) + return 5; + else if(text.length%100 <= 3) + return 3; + else return Math.floor(text.length%100); + +} +} +searchFun(control:any,i:number,option,flag){ +if(flag == 1) { +console.log(control,this.getQuestionControl().at(1)); +control = this.getQuestionControl().at(1) +} +if (option == 'city' && flag ==1) { + control.controls['citySearch'].valueChanges + .pipe(takeUntil(this._onDestroy)) + .subscribe(() => { + this.SearchCity(control.controls['citySearch'].value, i); + }) +} +if (option == 'state') { + + control.controls['stateSearch'].valueChanges + .pipe(takeUntil(this._onDestroy)) + .subscribe(()=>{ + this.searchState(control.controls['stateSearch'].value) + }) +} +if (option == 'pin' && flag ==1) { + + control.controls['pinSearch'].valueChanges + .pipe(takeUntil(this._onDestroy)) + .subscribe(()=>{ + this.searchPin(control.controls['pinSearch'].value,i) + }) +} +if (option == 'city' && flag ==2) { + control.controls['citySearch'].valueChanges + .pipe(takeUntil(this._onDestroy)) + .subscribe(() => { + this.SearchAlternativeCity(control.controls['citySearch'].value, i); + }) +} +if (option == 'pin' && flag ==2) { + + control.controls['pinSearch'].valueChanges + .pipe(takeUntil(this._onDestroy)) + .subscribe(()=>{ + this.searchAlternativePin(control.controls['pinSearch'].value,i) + }) +} +} +searchPin(val:any,index:number){ +if(!this.pincodeData[index]){ + return +} +let searchValue=val +if(!searchValue){ + this.pincodeDataValue[index]=this.pincodeData[index].slice() + return +}else{ + searchValue=searchValue.toLowerCase() +} +this.pincodeDataValue[index]=this.pincodeData[index].filter(value=>value.pincode.toLowerCase().indexOf(searchValue) > -1) +} +SearchCity(val: any, i: number) { +if (!this.cityData[i]) { + return +} +let searchValue = val +if (!searchValue) { + // this.filteredCity.next(this.cityData[i].slice()) + this.cityDataValue[i]=this.cityData[i].slice() + return +} else { + searchValue = searchValue.toLowerCase() +} +this.cityDataValue[i]=this.cityData[i].filter(value => value.city_name.toLowerCase().indexOf(searchValue) > -1) +// this.filteredCity.next( +// this.cityData[i].filter(value => value.city_name.toLowerCase().indexOf(searchValue) > -1) +// ) + +} +searchAlternativePin(val:any,index:number){ +if(!this.pincodeData[index]){ + return +} +let searchValue=val +if(!searchValue){ + this.alertnativePincodeData[index]=this.pincodeData[index].slice() + return +}else{ + searchValue=searchValue.toLowerCase() +} +this.alertnativePincodeData[index]=this.pincodeData[index].filter(value=>value.pincode.toLowerCase().indexOf(searchValue) > -1) +} +SearchAlternativeCity(val: any, i: number) { +if (!this.cityData[i]) { + return +} +let searchValue = val +if (!searchValue) { + // this.filteredCity.next(this.cityData[i].slice()) + this.alertnativeCityData[i]=this.cityData[i].slice() + return +} else { + searchValue = searchValue.toLowerCase() +} +this.alertnativeCityData[i]=this.cityData[i].filter(value => value.city_name.toLowerCase().indexOf(searchValue) > -1) +// this.filteredCity.next( +// this.cityData[i].filter(value => value.city_name.toLowerCase().indexOf(searchValue) > -1) +// ) + +} +searchState(val: any) { + +if (!this.stateData) { + return +} +let searchVal = val +if (!searchVal) { + this.filteredState.next(this.stateData.slice()) + return +} +else { + searchVal = searchVal.toLowerCase() +} +this.filteredState.next( + this.stateData.filter(res => res.name.toLowerCase().indexOf(searchVal) > -1) +) +} +selectedAddressType(e: any) { +this.placeholderName = 'Estimated area of the ' + e; +} +remarksEnableFun() { +// console.log(this.getQuestionControl().at(0).get('individuals')) +let applicant_arr = this.getQuestionControl().at(0).get('individuals').value +if(applicant_arr && applicant_arr.length > 0) { + let returnVal= false + if(applicant_arr.filter(vv=>vv.is_person_met == true).length == 0) { + // this.getQuestionControl().at(0)['controls'].general_remark.setValidators(Validators.required) + // this.getQuestionControl().at(0)['controls'].general_remark.updateValueAndValidity(); + this.getQuestionControl().at(0)['controls'].person_met_entered.setValidators(Validators.required) + this.getQuestionControl().at(0)['controls'].designation_entered.setValidators(Validators.required) + this.getQuestionControl().at(0)['controls'].relation_entered.setValidators(Validators.required) + this.getQuestionControl().at(0)['controls'].relation_to.setValidators(Validators.required) // return true + // this.getQuestionControl().at(0)['controls'].person_met_entered_pic.setValidators(Validators.required) + returnVal = true + } + else { + this.getQuestionControl().at(0)['controls'].person_met_entered.setValue(''); + this.getQuestionControl().at(0)['controls'].designation_entered.setValue(''); + this.getQuestionControl().at(0)['controls'].relation_entered.setValue(''); + this.getQuestionControl().at(0)['controls'].relation_to.setValue(''); + // console.log(this.getQuestionControl().at(0)['controls'].general_remark.value) + // this.getQuestionControl().at(0)['controls'].general_remark.clearValidators(); + // this.getQuestionControl().at(0)['controls'].general_remark.updateValueAndValidity(); + this.getQuestionControl().at(0)['controls'].person_met_entered.clearValidators(); + this.getQuestionControl().at(0)['controls'].designation_entered.clearValidators(); + this.getQuestionControl().at(0)['controls'].relation_entered.clearValidators(); + this.getQuestionControl().at(0)['controls'].relation_to.clearValidators(); + // this.getQuestionControl().at(0)['controls'].person_met_entered_pic.clearValidators() + // return false + returnVal = false + } + this.getQuestionControl().at(0)['controls'].person_met_entered.updateValueAndValidity(); + this.getQuestionControl().at(0)['controls'].designation_entered.updateValueAndValidity(); + this.getQuestionControl().at(0)['controls'].relation_to.updateValueAndValidity(); + this.getQuestionControl().at(0)['controls'].relation_entered.updateValueAndValidity(); + // this.getQuestionControl().at(0)['controls'].person_met_entered_pic.updateValueAndValidity(); + return returnVal +} +// debugger; +} + +setValidationForRemarks(value_neighbourhood_status) { +let control= this.getQuestionControl().at(3)['controls']['neighbour_reference_remark'] +console.log(value_neighbourhood_status,control) +if(value_neighbourhood_status == 'Could not verify' || value_neighbourhood_status == 'Negative') { + control.setValidators(Validators.required) +} +else { + control.clearValidators() +} +control.updateValueAndValidity(); +} +checkSpecifyField() { +let field=this.getBusinessInfoControls().at(1)['controls']['business_is_pd_visited_yes'].value +// console.log(field); +if(field && field.filter(vv=>vv == 'Others (Please specify)').length > 0) { + return true +} +return false +} +ngOnDestroy() { + console.log("Common ques component destroyed"); + if(this.firstFormGroup.dirty){ + this.onSubmit('go_back'); +// return this.constant.chekAlertOnLeave().then(res=>{ +// console.log(res) +// return res +// }) + // return true; +} +} +} diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/dynamic-docs-form/dynamic-docs-form.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/dynamic-docs-form/dynamic-docs-form.component.html new file mode 100644 index 0000000..982fa3b --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/dynamic-docs-form/dynamic-docs-form.component.html @@ -0,0 +1,44 @@ + + + +
Documents to be photographed/scanned
+
+
+ +
+ +
+
+
+ {{item.value.placeholder}}
+
+ Yes       + No +
+

+
+
+
+ +
+ + + + + + + +
+
+ + + + + Required + +
+
+ +
+
+ \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/dynamic-docs-form/dynamic-docs-form.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/dynamic-docs-form/dynamic-docs-form.component.scss new file mode 100644 index 0000000..7e871cb --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/dynamic-docs-form/dynamic-docs-form.component.scss @@ -0,0 +1,17 @@ +input{ + height:40px; + } + + .mat-form-field-label { + white-space: normal; + } + + textarea.mat-input-element { + padding: 0px 0; + margin: 5px 0; + } + + .mat-input-placeholder { + white-space: normal; + } + \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/dynamic-docs-form/dynamic-docs-form.component.spec.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/dynamic-docs-form/dynamic-docs-form.component.spec.ts new file mode 100644 index 0000000..b9a6ee4 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/dynamic-docs-form/dynamic-docs-form.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DynamicDocsFormComponent } from './dynamic-docs-form.component'; + +describe('DynamicDocsFormComponent', () => { + let component: DynamicDocsFormComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DynamicDocsFormComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(DynamicDocsFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/dynamic-docs-form/dynamic-docs-form.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/dynamic-docs-form/dynamic-docs-form.component.ts new file mode 100644 index 0000000..afb70f0 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/dynamic-docs-form/dynamic-docs-form.component.ts @@ -0,0 +1,84 @@ +import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import { FormGroup, FormBuilder, FormArray, FormControl, Validators } from '@angular/forms'; + +@Component({ + selector: 'app-dynamic-docs-form', + templateUrl: './dynamic-docs-form.component.html', + styleUrls: ['./dynamic-docs-form.component.scss'] +}) +export class DynamicDocsFormComponent implements OnInit { + @Input() docs_array_value:any; + @Input() form_group:FormGroup; + @Output() eventCapturePic = new EventEmitter(); + camera_btn: any =[]; + @Input() doc_answers:any + constructor(private fb:FormBuilder) { + } + + ngOnInit() { + console.log("child >>>",this.docs_array_value,this.form_group,this.doc_answers) + // this.docs_array_value=res['records'].docs_to_be_collected + if(this.docs_array_value.length !=0){ + // this.docsCollectedForm.addControl('docs_to_be_sighted', this.fb.array([])) + let control:any=this.form_group.controls['docs_to_be_sighted'] + this.docs_array_value.forEach((data,index)=>{ + control.push(this.createDocsArray(data)) + control.controls[index].addControl(data.pd_doc_to_be_collect_id,new FormControl('',Validators.required)) + }) + console.log(this.form_group); + } + } + ngOnChanges() { + console.log(this.doc_answers); + // debugger; + setTimeout(()=>{ + console.log(this.doc_answers); + if(this.doc_answers != null) { + if(this.doc_answers.docs_to_be_sighted != null && this.doc_answers.docs_to_be_sighted.length > 0){ + this.doc_answers.docs_to_be_sighted.forEach((doc_value,index)=>{ + if(doc_value.hasOwnProperty('img')){ + this.docs_change_fun(index,'yes') + } + else if(doc_value.hasOwnProperty('reason')){ + this.docs_change_fun(index,'no'); + } + }) + console.log(this.form_group,this.form_group.get('docs_to_be_sighted')) + this.form_group.get('docs_to_be_sighted').patchValue(this.doc_answers.docs_to_be_sighted) + } + } + },1000) + } + createDocsArray(data){ + console.log(data); + return this.fb.group({ + control_name:[data.pd_doc_to_be_collect_id], + placeholder:[data.doc_name], + + }) + } + docs_change_fun(index,value){ + console.log(index,value); + let control:any=this.form_group.controls['docs_to_be_sighted'] + if(value == 'yes'){ + this.camera_btn[index]=true + control.controls[index].removeControl('reason') + control.controls[index].addControl('img',new FormControl('')) + control.controls[index].addControl('is_new',new FormControl('')) + } + else if(value == 'no'){ + + this.camera_btn[index]=false + control.controls[index].removeControl('img') + control.controls[index].removeControl('is_new') + control.controls[index].addControl('reason',new FormControl('',Validators.required)); + } + + } + // capture(index,item_obj) { + // item_obj.controls['is_new'].setValue(1); + // this.eventCapturePic.emit({controls:item_obj.controls['img'],img_name:item_obj.value.placeholder,form_id:'24'}) + // } + + +} diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/employer-info/employer-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/employer-info/employer-info.component.html new file mode 100644 index 0000000..03d4f7d --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/employer-info/employer-info.component.html @@ -0,0 +1,1047 @@ +

+
+ {{pdDetails.applicants_details[0].applicant_name}} {{pdDetails.lender_applicant_id ? '('+pdDetails.lender_applicant_id+')' : ''}}, {{pdDetails.customer_segment_abbr}} - + {{pdDetails.subproduct_abbr}}
+ FI Questions +
+
+ +
+

+ +
+
+ + + General Section +
+
+
+ Applicants +
+
+ Is Person Met +
+
+ +
+
+
+ {{applicant.value.applicant_name}} +
+
+ + + + +
+

+
+
+
+ +
+ +
+ + + + Selfie of the Person Met +
+
+
+ +
+ + ID Proof of the person +
+
+
+
+
+ +
+ + Is the Employer/ Manager available during FI visit? + + Yes + No + + + Required + + + + Anyone met during FI visit at initiated address? + + Yes + No + + + Required + +
+
+
+ + Name of Person Met + + + Person Name required + +
+
+
+ +
+ + + + +
+
+
+
+ + +
+
+ + + Employment Information + + +
+ + Enter name of Employer/Manager + + + Name Required + + + Designation of the person met + + + {{item.name.split('of')[0]}} + + + Designation required + + +
+
+ +
+ +
+ + + + Selfie Photograph with Employer/Manager + +
+
+
+
+ + Photograph of “Photo ID card of the Employer/Manager" + + {{item}} + + + + Specify Photo ID card of the Employer/Manager + + +
+
+
+ + +
+ + + + +
+
+ +
+
+ + Employer’s/Manager’s Company ID card / Visiting Card provided”? + + Yes + No + + Required + +
+
+
+ + +
+ + + +
+
+ + Salary Amount Confirmed from Employer/Manager + + Yes + No + + Required + +
+ + Gross Salary + + + + Net Salary + + + + + Select + Bank Transfer + Paid in Cash + Both Bank Transfer & Cash + + Required + + + + {{"₹"}} + {{getEmployer_details['controls']['amount_paid_through_bank'].value | numberToWords}} Only + Given Value is + More than Net Salary + Given Value is + Less than Net Salary + + + + {{"₹"}} + {{getEmployer_details['controls']['amount_paid_in_cash'].value | numberToWords}} Only + Given Value is More + than Net Salary + Given Value is Less + than Net Salary + +
+

Date of Salary

+ + + Select + + {{date.date}} + + + Required + + + + + Select + + {{date.date}} + + + Required + + +
+
+ + Why salary amount was not confirmed by employer? + + + + +
+ +
+
+ + Year + + Higer than business + vintage + Year Required + + + + Month + + Higer than business + vintage + +
+
+ +
+ + + +
+
Documents Sighted of applicant employment During FI
+


+
+
+ + Salary register + + Select + Yes + No + + Salary register seen Required + +
+
+
+ + +
+ + + +
+
+ +
+
+ + Attendance Register + + Select + Yes + No + + Attendance register Required + +
+
+
+ + +
+ + + +
+
+ +
+
+ + Cash voucher + + + Select + Yes + No + + Cash Voucher Required + +
+
+
+ + +
+ + + +
+
+ +
+
+ + Salary Certificate + + + Select + Yes + No + + Salary Certificate Required + +
+
+
+ + +
+ + + +
+
+ +
+
+ + Salary Slip + + + Select + Yes + No + + Salary slip Required + +
+
+
+ + +
+ + +
+
+ + Others please specify + + + Select + Yes + No + +Other Document Required + + +
+
+ + Specify the Document + + Required + +
+
+
+ + +
+ + + +
+
+ +
+ + Why Documents are not available? + + {{item}} + + Required + + + Specify the reason + + +
+
+ + + +
+
+
Office Setup Photographs
+


+
+
+ +
+
+
+ +
+ Office Photograph {{i+1}} +
+
+
+ No Photographs Found
+
+ + +
+


+
+ + + +
+
+
Name board/Entrance photograph
+


+
+
+ +
+
+
+ +
+ Name Board {{i+1}} +
+
+
+ No Photographs Found
+
+ + +
+


+
+ +
+ + +
+ +
+ +
+ + Credit Manager Special Requests + + +
+ + + +
+
+ + +
+ + +
+
+ + + + + + Address Information + + + + + + + Address is Required + + + + + + + close + + + + Select + {{SL.name}} + + State is Required + + + + + + close + + + Select + {{CL.city_name}} + + City is Required + + + + + + + close + + + Select + {{PL.pincode}} + + Pincode is Required + +
+
+
+ +
+
+ +
+
+
+
+

+
+
+ + + Alternative Address Required + + + + + + close + + + + Select + {{SL.name}} + + + + + + + close + + + Select + {{CL.city_name}} + + + + + + + + close + + + Select + {{PL.pincode}} + + + + + + Pincode Required + + + + + + + Reason Required + + + +
+
+
+
+ + + + Select + {{m_addressType.address_type}} + + Address Type is Required + +
+ + + +
+ + + Select + {{m_locality.locality_name}} + + + + Locality is Required + + + + + + + + + +
+
+ + Approach to FI location + + Select + {{data.description}} + + Approach to pd location is Required + +
+
+
+ +
+ + + + Approach to pd location pic is Required +
+
+
+
+ + Comment on locality + + Select + {{data.rating | titlecase}} + + + Comment on locality is Required + +
+
+
+ + +
+ +
+ + + + +
+ + + Final Remarks + +
+

Comment on Footfall in the market where the B2C outlet is located…

+ + + Heavy Footfall ( lots of customers in the locality / marketplace ).
+ Medium Footfall ( Medium no of customers in the locality / marketplace ).
+ Low Footfall ( Few customers seen in the locality / marketplace ).
+ +

+
Required
+
+ + + Is there a competetion to the applicant's business in the location + + Select + Yes + No + + Required + + + + + + Required + + + + Any demolition activity seen in the locality by PD officer + + Select + Yes + No + + Required + + + + + + Required + + + Any sealing activity observed in the locality by PD officer + + Select + Yes + No + + Required + + + + + + Required + +
+ + +
+ +
+
+ + + + + + Submit + + Final Status of visit + + + Positive + Negative + Could not verify + + Required + + + Comments + + +
+ Neighbourhood check +
+ + Existence of organization/office confirmed by neighbour + + Select + Yes + No + + Required + +
+ + Year + + Higer than business + vintage + Year Required + + + + Month + + Higer than business + vintage + +
+
+
+ + + + +
+
+ + +
+ +
+
+ \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/employer-info/employer-info.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/employer-info/employer-info.component.scss new file mode 100644 index 0000000..3203770 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/employer-info/employer-info.component.scss @@ -0,0 +1,60 @@ +.paragraph_change { + color: #fff !important; + background-color: #e00201 !important; + } + + .mat-button, .mat-raised-button{ + background-color: #e24533; + color: white; + +} +.mat-stroked-button { + color: #e24533; + margin-right: 10px +} +.mat-button-div{ + float: right; + margin-top: 5%; + margin-bottom: 2%; +} +.mat-radio-group > .mat-radio-button,span { + margin: 10px; +} + + +::ng-deep .mat-slide-toggle.mat-checked:not(.mat-disabled) .mat-slide-toggle-thumb { + background-color: blue; /*replace with your color*/ +} + +::ng-deep .mat-slide-toggle.mat-checked:not(.mat-disabled) .mat-slide-toggle-bar { + background-color: skyblue; /*replace with your color*/ +} + +::ng-deep .mat-radio-button.mat-accent.mat-radio-checked .mat-radio-outer-circle{ + border-color:rgb(66, 134, 244); +} + +::ng-deep .mat-radio-button.mat-accent .mat-radio-inner-circle{ + color:rgb(66, 134, 244); + background-color:rgb(66, 134, 244) ; +} + +.mat-radio-button.mat-accent .mat-radio-ripple .mat-ripple-element { + background-color:rgb(255, 37, 37); +} +.mat-form-field { + // margin-top: 16px; + width: 100%; +} + + .whole_form { + @media(min-width:500px) { + margin-left: 5%; + margin-right: 5%; + } + } + + hr{ + width: 100%; + border-bottom: 2px solid lightcoral; + } \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/employer-info/employer-info.component.spec.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/employer-info/employer-info.component.spec.ts new file mode 100644 index 0000000..d415353 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/employer-info/employer-info.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EmployerInfoComponent } from './employer-info.component'; + +describe('EmployerInfoComponent', () => { + let component: EmployerInfoComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EmployerInfoComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EmployerInfoComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/employer-info/employer-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/employer-info/employer-info.component.ts new file mode 100644 index 0000000..8509481 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/employer-info/employer-info.component.ts @@ -0,0 +1,1708 @@ +import { Component, OnInit, ViewChild, Inject } from '@angular/core'; +import { MatStepper, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; +import { FormControl, FormGroup, FormBuilder, Validators, FormArray } from '@angular/forms'; +import { ReplaySubject, Subject } from 'rxjs'; +import { DatePipe } from '@angular/common'; +import { ActivatedRoute, Router } from '@angular/router'; +import { PdTrigerService } from 'app/personal-discussion/pd-service/pd-triger.service'; +import { NotifierService } from 'angular-notifier'; +import { AwsService } from 'app/AwsService/aws.service'; +import { CommonQuesComponent } from '../common-ques/common-ques.component'; +import { takeUntil } from 'rxjs/operators'; + +@Component({ + selector: 'app-employer-info', + templateUrl: './employer-info.component.html', + styleUrls: ['./employer-info.component.scss'] +}) +export class EmployerInfoComponent implements OnInit { + stepperInfo= [{ + form_name:'General Section', + form_id:18, + stepper_index:0, + }, + { + form_name:'Employer information', + form_id:"12", + stepper_index:1 + }, + { + form_name:'Credit Manager Queries', + form_id:24, + stepper_index:2, + is_dynamic:true + }, + { + form_name:'Address Information', + form_id:5, + stepper_index:3, + is_dynamic:true + },{ + form_name:'Neighbourhood Details', + form_id:19, + stepper_index:4, + is_dynamic:true + },{ + form_name:'Final Remarks', + form_id:20, + stepper_index:5, + is_dynamic:true + },{ + form_name:'Submit', + form_id:'COMMENTS', + stepper_index:5, + is_dynamic:true + },] + // public person_met_entered:FormControl= new FormControl('') + // public designation_entered:FormControl= new FormControl('') + // public relation_entered:FormControl= new FormControl('') + // public relation_to:FormControl= new FormControl('' + + + employerForm: FormGroup; + matExpanded:number = 0; + isDisplay:any = []; + isDisplay2:any = []; + isOrganisationOwner: any = []; + photoIdCardList:any=[ + "Aadhaar card", "Electoral Photo Identity Card (EPIC) card", "PAN card", "Driving license" , "Others" + ] + docNotAvailList:any=[ + "Documents were not shared by Employer", "Documents are not issued by Employer", "Documents were not available", "Employer was not available", "Others (please specify)" + ] + public dateonly: any = [{date:1,isdisabled:false},{date:2,isdisabled:false},{date:3,isdisabled:false},{date:4,isdisabled:false},{date:5,isdisabled:false},{date:6,isdisabled:false},{date:7,isdisabled:false},{date:8,isdisabled:false},{date:9,isdisabled:false},{date:10,isdisabled:false},{date:11,isdisabled:false},{date:12,isdisabled:false},{date:13,isdisabled:false},{date:14,isdisabled:false},{date:15,isdisabled:false},{date:16,isdisabled:false},{date:17,isdisabled:false},{date:18,isdisabled:false},{date:19,isdisabled:false},{date:20,isdisabled:false},{date:21,isdisabled:false},{date:22,isdisabled:false},{date:23,isdisabled:false},{date:24,isdisabled:false},{date:25,isdisabled:false},{date:26,isdisabled:false},{date:27,isdisabled:false},{date:28,isdisabled:false},{date:29,isdisabled:false},{date:30,isdisabled:false},{date:31,isdisabled:false}]; + public todate: any[] = this.dateonly; + neighbour_status_list:any=[{id:'',name:'Select'},{id:'Positive',name:'Positive'},{id:'Negative',name:'Negative'},{id:'Could not verify',name:'Could not verify'}] + pdlocation: any = []; + cmtlocality: any = []; + pdDetails: any = {pd_id:"1725"}; + // FormId: any; + existCompanyList: any = []; + mergeCompanyApplicant: any=[]; + applicants: any=[]; + currentDate: any; + pipe: any = new DatePipe('en-US'); + users: string; + spinner_access:boolean = false; + docs_tobe_collect: any = []; + creditManagerAnswer: any = null; + addressesList: any; + cityData: any=[]; + search: any; + pincodeData: any=[]; + cityDataValue: any=[]; + pincodeDataValue: any=[]; + alertnativeCityData: any=[]; + alertnativePincodeData: any=[]; + stateData: any =[]; + protected _onDestroy = new Subject(); + public filteredCity: ReplaySubject = new ReplaySubject(1); + public filteredState:ReplaySubject=new ReplaySubject(1) + addressTypes: any =[]; + locality: any =[]; + uomData: any =[]; + placeholderName: string = ''; + companyRelationshipList: any = []; + relationshipList: any = []; + customer_seg_abbr: any; + generalExistBusinessYear: number; + generalExistBusinessMonth: number; + notifier: NotifierService; + get questions() { return this.employerForm.get('questions');} + get getEmployer_details() {return this.questions.get([2]).get('employer_details')} + get getDocsSightedGroup() {return this.questions.get([2]).get('docs_sighted')} + + employerform_pdinfo:any; + + @ViewChild('stepper') private myStepper: MatStepper; + + public designationFilterCtrl:FormControl = new FormControl(); + public relationFilterCtrl:FormControl = new FormControl(); + public filteredcompanyRelationshipList:ReplaySubject = new ReplaySubject(1); + public filteredrelationshipList:ReplaySubject = new ReplaySubject(1); + + constructor(private actRoute:ActivatedRoute,private quesService:PdTrigerService,private router:Router, + @Inject(MAT_DIALOG_DATA)public data,private _formBuilder:FormBuilder, + notifier:NotifierService,private _awsService:AwsService,private dialogRef:MatDialogRef) { + this.notifier=notifier + this.pdDetails = this.data + console.log(this.pdDetails); + this.docs_tobe_collect = this.data.docs_collected + // this.questionDetails=this.router.getCurrentNavigation().extras.state.questionDetails + // this.FormId=this.router.getCurrentNavigation().extras.state.FormId + this.applicants = this.pdDetails.applicants_details; + this.customer_seg_abbr = this.pdDetails.customer_segment_abbr + console.log("constr",this.pdDetails,this.docs_tobe_collect) + if(this.pdDetails.lender_short_name == 'CLIX' || this.pdDetails.lender_short_name == 'MWISE' || this.pdDetails.prod_catagory == 'LAEP') + { + let Index = this.stepperInfo.findIndex(vv=>vv.form_id == 'COMMENTS') + this.stepperInfo[Index].stepper_index+=1 + } + if(this.docs_tobe_collect == null || this.docs_tobe_collect == undefined || this.docs_tobe_collect.length == 0) { + // this.stepperInfo + for(let value of this.stepperInfo) { + if(value.is_dynamic) { + value.stepper_index-=1 + } + } + } + this.users = this._awsService.getlocale() + this.generalExistBusinessYear=100; + this.generalExistBusinessMonth=12; + } + + ngOnInit() { + // this.loadingProvider.dataLoader() + this.employerForm=this._formBuilder.group({ + questions:this._formBuilder.array([this.addGeneralControls(),this.addAddressControls(), + this.addEmployerInfoForm(),this.addNeighbourhoodControls(),this.addFinalRemarksControls(), + this._formBuilder.group({ + final_comments:[''], + final_visit_status:['',Validators.compose([Validators.required])], + company_existence_neighbour_confirmed:['',Validators.required], + company_existence_years:[''], + company_existence_months:[''], + form_id:["COMMENTS"], + form_name:["Comments"] + }), this.addCreditManagerQueries()]) + + }) + + console.log("Current customer segment",this.customer_seg_abbr); + // console.log(this.employerForm); + + console.log(this.employerForm.value) + this.getMasters(); + this.currentDate = this.pipe.transform(new Date(), 'yyyy-MM-dd hh:mm:ss'); + this.addGeneralIndividualsGroup() + this.getFormDatas() + this.filterList() + console.log("Form",this.employerForm.value) + } + + filterList() { + this.relationFilterCtrl.valueChanges.pipe().subscribe(()=>{ + this.applyFilter(this.relationFilterCtrl.value,this.filteredrelationshipList,this.relationshipList,'name') + }) + this.designationFilterCtrl.valueChanges.pipe().subscribe(()=>{ + this.applyFilter(this.designationFilterCtrl.value,this.filteredcompanyRelationshipList,this.companyRelationshipList,'name') + }) + + } + getInitialAddress(){ + // const control=this.pdQuestionAddress.controls['addresses'] + this.quesService.getAddressesDetails(this.pdDetails.pd_id).subscribe(res=>{ + if(res.dataStatus == true){ + this.addressesList = res.records.filter(item => item.isactive == 1 && item.assigned_pd == this.pdDetails.pd_id); + + if(this.addressesList.length > 0){ + this.addressesList.forEach((datas,index)=>{ + this.getCityAndPincodeDetails(datas.fk_state,index,1) + + let obj ={ + 'address': datas.addressline1, + 'address_type': '', + 'address_type_others': '', + 'state': datas.fk_state, + 'city': datas.fk_city, + 'pincode':datas.pincode_id, + 'pd_address_id': datas.pd_address_id, + 'pincode_others': datas.other_pincode, + 'locality': '', + 'locality_others': '', + // 'locality_mixuse':'', + 'pd_location': '', + 'comment_locality': '', + 'estimated_area': '', + 'uom': '', + 'uom_others': '' + } + + // control.push(this.initAddress(obj)) + this.getQuestionControl().at(1).patchValue(obj) + console.log(this.employerForm.value) + }) + } + else{ + // control.push(this.initAddress('')) + } + } + else{ + // control.push(this.initAddress('')) + } + }) + } + + getCityAndPincodeDetails(stateID: string,i,flag) { + + //this.pdQuestionAddress.controls['addresses']['controls'].controls + this.quesService.getStateWiseCities(stateID).subscribe(data => { + if (data.status == 200) { + this.cityData[i] = data.records.cities; + this.search=this.cityData[i] + this.pincodeData[i] = data.records.pincode; + + //this.filteredCity.next(this.cityData[i].slice()) + if(flag== 1){ + this.cityDataValue[i]=this.cityData[i].slice() + // this.pincodeData[i] = data.records.pincode; + this.pincodeDataValue[i]=this.pincodeData[i].slice() + } + else if(flag == 2){ + this.alertnativeCityData[i]=this.cityData[i].slice() + this.alertnativePincodeData[i]=this.pincodeData[i].slice() + } + } + //FOR PINCODE FREE TEXT + // let pin + // if(pincode != ''){ + // if(pincode != 1){ + // this.pincodeValue[i]=this.pincodeData[i].filter(res=>res.pincode_id == pincode).map(val=>val.pincode)[0] + // //this.pincodeValue[i]=[].concat.apply([],this.pincodeValue[i]) + + + // } + // } + }); + } + + getMasters() { + this.quesService.getAllMasterDatas('PDLOCATIONAPPROACH').subscribe(res=> + { + this.pdlocation = res; + if(this.pdlocation.dataStatus == true) + { + this.pdlocation = this.pdlocation.records.filter(loca=>loca.isactive ==1); + } + }) + this.quesService.getAllMasterDatas('COMMENTSONLOCALITY').subscribe(res=> + { + this.cmtlocality = res; + if(this.cmtlocality.dataStatus ==true) + { + this.cmtlocality = this.cmtlocality.records.filter(loc=>loc.isactive ==1); + } + }); + this.quesService.getCompaniesListsForBusiness(this.pdDetails.pd_id).subscribe(res=>{ + if(res.dataStatus==true){ + this.existCompanyList=res.records.filter(val=>val.is_active == true) + console.log(this.existCompanyList) + } + let modifyCompanyList:any=[] + if(this.existCompanyList.length>0){ + modifyCompanyList=this.existCompanyList.map(element=>{ + return {id:element.company_order_id.toString(),name:element.company_name,group_id:1}; + }); + this.mergeCompanyApplicant.push({groupName: 'COMPANIES', groupValues: modifyCompanyList }) + + } + let modifyApplicantList:any=[] + if(this.applicants.length>0){ + modifyApplicantList=this.applicants.map(element=>{ + return {id:element.pd_co_applicant_id,name:element.applicant_name,group_id:2}; + }) + this.mergeCompanyApplicant.push({groupName:'APPLICANTS',groupValues:modifyApplicantList}) + + } + console.log("company&Applicant",this.mergeCompanyApplicant) + }) + this.quesService.getAllMasterDatas('STATE').subscribe(res=>{ + this.stateData=res['records'].filter(val=>val.isactive == 1); + this.filteredState.next(this.stateData.slice()) + + }) + this.quesService.getAllMasterDatas('ADDRESSTYPE').subscribe(res=> + { + if(res['dataStatus']==true){ + this.addressTypes = res['records'].filter(add=>add.isactive==1); + // this.cacheObservable.register('addressType',this.addressTypes).subscribe(res=>{ + // this.data$=res.get$ + // }) + } + // this.cacheObservable.loadFromObservable() + }) + this.quesService.getAllMasterDatas('LOCALITY').subscribe(res=> + { + if(res['dataStatus']==true) + { + this.locality = res['records'].filter(loc=>loc.isactive==1); + } + }) + this.quesService.getAllMasterDatas('UOM').subscribe(res=>{ + this.uomData=res['records'].filter(val=>val.isactive == 1 && val.is_land_uom != 0) + }) + this.quesService.getAllMasterDatas('COMPANYRELATIONSHIPS').subscribe(rr=>{ + if(rr['dataStatus']) { + this.companyRelationshipList = rr['records'].filter(vv=>vv.isactive == '1'); + this.filteredcompanyRelationshipList.next(this.companyRelationshipList.slice()) + let temp = [{master_name:'COMPANYRELATIONSHIPS',master_data:this.companyRelationshipList}] + this.employerform_pdinfo = this.pdDetails + this.employerform_pdinfo.masterData= temp; + } + + }) + // this.quesService.getAllMasterDatas('RELATIONSHIPS').subscribe(rr=>{ + // this.relationshipList = rr['records'].filter(vv=>vv.isactive == '1'); + // this.filteredrelationshipList.next(this.relationshipList.slice()) + // }) + } + // ngOnChanges() { + // // console.log("Employer infor form Group",this.form_group,this.getEmployerForm,this.pd_info,this.pd_info['masterData'],this.pd_info.applicants_details); + // if(this.pd_info && this.pd_info.masterData && this.pd_info.masterData.length >0) { + // this.companyRelationshipList = this.pd_info.masterData.filter(v=>v.master_name == "COMPANYRELATIONSHIPS")[0].master_data; + // this.filteredcompanyRelationshipList.next(this.companyRelationshipList.slice()) + + // console.log("Empleo",this.filteredcompanyRelationshipList); + // // debugger; + // } + // } + applyFilter(filtered_text,filter_list,raw_list,obj_name) { + if (!raw_list) { + return; + } + // get the search keyword + let search = filtered_text; + if (!search) { + filter_list.next(raw_list.slice()); + return; + } else { + search = search.toLowerCase(); + } + // filter the banks + filter_list.next( + raw_list.filter(bank => bank[obj_name].toLowerCase().indexOf(search) > -1) + ); + } + ConvertMonthintoYear(e) { + + let how_long_year = this.getEmployer_details['controls'].how_long_year.value; + console.log(how_long_year) + + this.getEmployer_details['controls']['how_long_month'].clearValidators(); + + let converted_month: number = +e%12; + let converted_year: number = e / 12; + + // console.log('e',e%12); + // console.log('e',e); + // console.log('e',e/12); + + if (how_long_year > this.generalExistBusinessYear) { + + this.getEmployer_details['controls']['how_long_year'].setValidators(Validators.compose([Validators.max(this.generalExistBusinessYear)])); + this.getEmployer_details['controls']['how_long_year'].setValue(''); + this.getEmployer_details['controls']['how_long_month'].setValue(''); + } + else { + if (how_long_year == this.generalExistBusinessYear && +converted_month > this.generalExistBusinessMonth) { + + this.getEmployer_details['controls'].controls['how_long_year'].setValidators(Validators.compose([Validators.max(this.generalExistBusinessYear)])); + + this.getEmployer_details['controls'].controls['how_long_month'].setValidators(Validators.compose([Validators.max(this.generalExistBusinessMonth)])); + + } else { + + this.getEmployer_details['controls'].how_long_year.setValue(+how_long_year + +Math.floor(converted_year)); + this.getEmployer_details['controls'].how_long_month.setValue(Math.floor(converted_month)); + + } + } + this.getEmployer_details['controls']['how_long_year'].updateValueAndValidity(); + this.getEmployer_details['controls']['how_long_month'].updateValueAndValidity(); + } + dynamicOnChangeValidations(choosed_value,controls_arr,value_compare) { + if(controls_arr.length && controls_arr.length >0) { + controls_arr.forEach(vv=>{ + if(choosed_value == value_compare) { + vv.setValidators(Validators.required); + } + else{ + vv.clearValidators(); + } + vv.updateValueAndValidity() + }) + } + } + + getFormDatas() { + let params = {'parent_pdid':this.pdDetails.parent_pd_id,'pd_id':this.pdDetails.pd_id,'pd_form_id':"25"} + this.quesService.getPDFormDetailsWithID(params).subscribe(result=>{ + // result['dataStatus']=false + if(result && result['dataStatus']) { + this.generateGroupControls(result['records'].questions) + } + else { + this.getInitialAddress(); + // this.getBusinessDocumentsSighted() + } + // this.loadingProvider.dismissLoader() + },err=>{ + console.log("getPDFormDetails Error",err) + // this.loadingProvider.dismissLoader(); + this.notifier.notify('error',"Network Error"); + }) + // this.quesService.getAllQuesSample().subscribe((result:any)=> { + // console.log("Result",result) + // if(result) { + // // this.generateGroupControls(result.questions) + // } + // }) + } + + generateGroupControls(datas) { + if(datas && datas.length > 0) { + // FOR ADDRESS FORM + let address_index = datas.findIndex(val=>val.form_id == "5") + if(address_index && datas[address_index]) { + if(datas[address_index].hasOwnProperty('state') && datas[address_index].state) { + this.getCityAndPincodeDetails(datas[address_index].state,0,1); + if(datas[address_index].hasOwnProperty('alternative_addresses') && datas[address_index].alternative_addresses && datas[address_index].alternative_addresses[0].alternative_state) { + this.getCityAndPincodeDetails(datas[address_index].alternative_addresses[0].alternative_state,0,2); + } + } + if(datas[address_index].hasOwnProperty('address_type') && datas[address_index].address_type) { + if(datas[address_index].address_type != 1) { + let selectedAddressType = this.addressTypes.filter(element => element.address_type_id == datas[address_index].address_type)[0]; + if(selectedAddressType != undefined && selectedAddressType.hasOwnProperty('address_type')){ + this.selectedAddressType(selectedAddressType.address_type); + } + } + else { + this.selectedAddressType(datas[address_index].address_type_others); + } + } + + + + } + + // FOR CREDIT MANAGER + let crdmngr_index = datas.findIndex(val=>val.form_id == "24") + if(crdmngr_index) { + // if(group_obj.form_id == "24" && group_obj.hasOwnProperty('docs_to_be_sighted') && group_obj.docs_to_be_sighted + // && this.docs_tobe_collect != null && this.docs_tobe_collect != undefined && this.docs_tobe_collect.length > 0) { + this.creditManagerAnswer = datas[crdmngr_index] + // } + } + // // FOR NEIGHBOURHOOD GROUP GENERATION + // let neighbour_group_index = datas.findIndex(val=>val.form_id == "19") + // if(neighbour_group_index) { + // this.toggleVisibility(datas[neighbour_group_index].neighbourhood_list[0].did_not_know_the_business_operation,0,1) + // this.toggleVisibility(datas[neighbour_group_index].neighbourhood_list[0].did_not_know_the_owner,0,2) + // for(let i=1; i < datas[neighbour_group_index].neighbourhood_list.length ; i++) { + // // datas[neighbour_group_index].neighbourhood_list.forEach(()=>{ + // let neighbour_obj= datas[neighbour_group_index].neighbourhood_list[i] + // this.toggleVisibility(neighbour_obj.did_not_know_the_business_operation,i,1) + // this.toggleVisibility(neighbour_obj.did_not_know_the_owner,i,2) + // // }) + // this.addNeighbourhoodGroup() + // } + // } + this.employerForm.get('questions').patchValue(datas); + + setTimeout(()=>{ + // FOR Employer info GROUP + let employer_group_index = datas.findIndex(val=>val.form_id == "12") + console.log(employer_group_index); + if(employer_group_index != -1) { + if(datas[employer_group_index]) { + let group_obj = datas[employer_group_index] + // For Documents Sighted + // if(group_obj.form_id == "13" && group_obj.hasOwnProperty('documents_sighted') && group_obj.documents_sighted == 'yes') { + // if(group_obj.documents_info) { + // group_obj.documents_info.forEach(doc=>{ + // this.addDocumentsGroup() + // }) + // } + // } + if(group_obj.hasOwnProperty('office_photographs') && group_obj.office_photographs && this.getQuestionControl().at(2).get('office_photographs')) { + group_obj.office_photographs.forEach(()=>{ + this.addMoreImage('office_photographs') + }) + } + // name board photo handling + if(group_obj.hasOwnProperty('nameboard_photographs') && group_obj.nameboard_photographs && this.getQuestionControl().at(2).get('nameboard_photographs')) { + group_obj.nameboard_photographs.forEach(()=>{ + this.addMoreImage('nameboard_photographs') + }) + } + // // For Other Documents images + // if(group_obj.form_id == "13" && group_obj.hasOwnProperty('other_documents') && group_obj.other_documents == 'yes') { + // if(group_obj.other_documents_info) { + // group_obj.other_documents_info.forEach(doc=>{ + // this.addOtherDocumentsGroup() + // }) + // } + // } + // // FOR STOCK IMAGES + // if(group_obj.form_id == "11" && group_obj.hasOwnProperty('images') && group_obj.images) { + // group_obj.images.forEach(()=>{ + // this.addMoreStockImage() + // }) + // } + } + } + + this.getQuestionControl().at(2).patchValue(datas[employer_group_index]) + },200) + console.log("final output",this.employerForm.value) + } + } + + // getBusinessDocumentsSighted() { + // this.quesService.getBusinessDocsToVendorForm(this.pdDetails.pd_id).subscribe(res=>{ + // if(res['dataStatus']) { + // let data= res['records']; + // if(data && data.length > 0) { + // let docs_value_arr:any=[] + // data.forEach(rr=>{ + // this.addDocumentsGroup() + // docs_value_arr.push({document_name:rr}); + // }) + + // let temp:any = {documents_sighted: "yes",documents_info:docs_value_arr} + // console.log("Current docs sighted value",docs_value_arr,temp,this.getBusinessInfoControls().at(0)) + // this.getBusinessInfoControls().at(0).patchValue(temp) + // } + // } + // }) + // } + + + + + // START OF FORM CONTROL NAME GROUPS + addGeneralControls() { + return this._formBuilder.group({ + individuals:this._formBuilder.array([]), + form_id:['18'], + form_name:["General Info"], + is_employer_available:['',Validators.required], + is_met_during_visit:[''], + person_met_entered:[''], + // designation_entered:[''], + // relation_entered:[''], + // relation_to:[''], + person_met_entered_pic:[''], + person_met_entered_id_proof:[''] + }) + } + addGeneralIndividualControls(applicant_obj) { + return this._formBuilder.group({ + is_person_met_id_proof:[''], + is_person_met_pic:[''], + is_person_met:[false], + pd_co_applicant_id:[applicant_obj.pd_co_applicant_id], + applicant_name:[applicant_obj.applicant_name] + }) + } + addAddressControls() { + return this._formBuilder.group({ + address:['',Validators.compose([Validators.required])], + state:['',Validators.compose([Validators.required])], + stateSearch:[''], + city:['',Validators.compose([Validators.required])], + citySearch:[''], + pincode:['',Validators.compose([Validators.required])], + pinSearch:[''], + alternative_addresses:this._formBuilder.array([ + this._formBuilder.group({ + alternative_address:[''], + alternative_state:[''], + stateSearch:[''], + alternative_city:[''], + citySearch:[''], + alternative_pincode:[''], + pinSearch:[''], + alternative_pincode_others:[''], + reason_for_alternative_address:[''] + }) + ]), + address_type:['',Validators.compose([Validators.required])], + address_type_others:[''], + locality:['',Validators.compose([Validators.required])], + locality_others:[''], + estimated_area:[''], + uom:[''], + uom_others:[''], + is_pd_done_on_initiated_address:[true], + pd_location:['',Validators.compose([Validators.required])], + pd_location_pic:[''], + comment_locality:['',Validators.compose([Validators.required])], + form_id:['5'], + form_name:["Address Info"], + }) + } + // addBusinessGroupControls() { + // if(this.customer_seg_abbr != 'SAL') { + // return this._formBuilder.group({ + // business_group:this._formBuilder.array([ + // this.addBusinessInfoControls(),this.addBusinessAssetControls(),this.addStockControls(), + // ]), + // form_id:["BUSINESS_GROUP"], + // form_name:["Business Group Info"] + // }) + // } + // else { + // return this._formBuilder.group({ + // form_id:["BUSINESS_GROUP"], + // form_name:["Business Group Info"] + // }) + // } + // } + // addStockControls() { + // return this._formBuilder.group({ + // form_name:"Stock Info", + // form_id:["11"], + // is_stock_photo:['',Validators.required], + // images:this._formBuilder.array([ + // // this._formBuilder.group({ + // // image:["https://lh3.googleusercontent.com/proxy/euOnni6JKoCJKwXq9Hq8c6fkRaxI5SYQVsHUwx_w_Wt_9zGXsABxnFsjRv7_E3Xer35VR1oalGBRKWdlwQPMo9SoDqOrmx9h7zqmAXMG37rcrpaU_jPXMXAdffKjB0M_zy3yQNJRpOKvqUlx2JmvB68r8cDCGbVUQvW8Zk2yoR4I23i4ZM7U"] + // // }), + // // this._formBuilder.group({ + // // image:["https://lh3.googleusercontent.com/proxy/euOnni6JKoCJKwXq9Hq8c6fkRaxI5SYQVsHUwx_w_Wt_9zGXsABxnFsjRv7_E3Xer35VR1oalGBRKWdlwQPMo9SoDqOrmx9h7zqmAXMG37rcrpaU_jPXMXAdffKjB0M_zy3yQNJRpOKvqUlx2JmvB68r8cDCGbVUQvW8Zk2yoR4I23i4ZM7U"] + // // }) + // ]) + // }) + // } + addImageControl() { + return this._formBuilder.group({ + image:[''] + }) + } + addCreditManagerQueries() { + return this._formBuilder.group({ + form_name:"Credit Manager Queries", + form_id:["24"], + docs_to_be_sighted:this._formBuilder.array([]) + }) + } + addEmployerInfoForm() { + return this._formBuilder.group({ + form_name:"Employer Information", + form_id:["12"], + // employer_details:this.getEmployerDetailsControls(), + // docs_sighted:this.getDocsSightedDetailsControls(), + // office_photographs:this._formBuilder.array([]), + // nameboard_photographs:this._formBuilder.array([]) + // docs_to_be_sighted:this._formBuilder.array([]) + }) + } + // START OF EMPLOYER FORM GROUP + getDocsSightedDetailsControls() { + return this._formBuilder.group({ + sal_reg_seen:['',Validators.compose([Validators.required])], + attendance_seen:['',Validators.compose([Validators.required])], + cash_voucher:['',Validators.compose([Validators.required])], + sal_certificate:['',Validators.required], + sal_slip:['',Validators.required], + other_doc:['',Validators.required], + other_doc_name:[''], + doc_not_available:[''], + doc_not_available_specify:[''], + + other_doc_pic:[''], + sal_reg_seen_pic:[''], + attendance_seen_pic:[''], + cash_voucher_pic:[''], + sal_certificate_pic:[''], + sal_slip_pic:[''], + }) + } + getEmployerDetailsControls() { + return this._formBuilder.group({ + name_person_met:['',Validators.compose([Validators.required])], + designation_person_met:['',Validators.compose([Validators.required])], + // proof image + person_met_pic:[''], + photo_id_card:[''], + photo_id_others:[''], + photo_id_card_pic:[''], + visiting_card:['',Validators.required], + visiting_card_pic:[''], + // salaray confirmed ? + confirm_salary:['',Validators.required], + gross_monthly_salary:[''], + net_monthly_salary:[''], + sal_amount_was_not_confirmed:[''], + // Mode of net salary + mode_of_getting_salary:[''], + amount_paid_through_bank:[''], + amount_paid_in_cash:[''], + // Date of Salary ques + from_date_the_salary_is_rcv:[''], + to_date_the_salary_is_rcv:[''], + // since how long working with this employer + how_long_year:['',Validators.compose([Validators.required,Validators.max(this.generalExistBusinessYear)])], + how_long_month:['',Validators.compose([Validators.max(12)])] + }) + } + // // END OF EMPLOYER FORM GROUP + + // addBusinessInfoControls() { + // return this._formBuilder.group({ + // officer_total:['',Validators.compose([Validators.required])], + // was_the_company_name_board_sighted:['',Validators.compose([Validators.required])], + // name_board_sighted_pic:['',Validators.compose([Validators.required])], + // documents_sighted:['',Validators.compose([Validators.required])], + // documents_info:this._formBuilder.array([]), + // other_documents:['',Validators.compose([Validators.required])], + // other_documents_info:this._formBuilder.array([]), + // office_photographs:this._formBuilder.array([]), + // form_name:["Business Info"], + // form_id:["13"] + // }) + // } + // addBusinessInfoDocsControls() { + // return this._formBuilder.group({ + // document_name:['',Validators.compose([Validators.required])], + // document_image:['',Validators.compose([Validators.required])] + // }) + // } + // addBusinessInfoOtherDocsControls() { + // return this._formBuilder.group({ + // document:[''], + // document_pic:[''] + // }) + // } + // addBusinessAssetControls() { + // return this._formBuilder.group({ + // business_is_pd_visited:['',Validators.compose([Validators.required])], + // business_is_pd_visited_pic:[''], + // business_is_pd_visited_yes:[''], + // specify_pd_visited:[''], + // business_asset_sight:['',Validators.compose([Validators.required])], + // business_sight_image:this._formBuilder.array([]), + // // business_pd_visited_remark:[''], + // form_name:["Business Assets"], + // form_id:["22"] + // }) + // } + + addNeighbourhoodControls() { + return this._formBuilder.group({ + form_id:["19"], + form_name:["Neighbourhood Details"], + // neighbourhood_list:this._formBuilder.array([this.addNeighbourListControls()]), + // neighbourhood_status:[''], + // neighbour_reference_remark:[''] + }) + } + // addNeighbourListControls() { + // return this._formBuilder.group({ + // neighbourhood_name:[''], + // do_know:[''], + // did_not_know_the_business_operation:[''], + // how_long_do_know_in_year:[''], + // how_long_do_know_in_month:[''], + // organisation_owner:[''], + // other_organisation_owner:[''], + // did_not_know_the_owner:[''], + // }) + // } + + addFinalRemarksControls() { + return this._formBuilder.group({ + form_name:["Final Remarks"], + form_id:["20"], + outlet_location:[''], + is_competition:[''], + demolition_activity:[''], + sealing_activity:[''], + appx_outlet_or_stores:[''], + comment_of_demolition_activity:[''], + comment_of_sealing_activity:[''], + + }) + } + // END OF FORM CONTROL NAME GROUPS + + // START OF GETTING PARTICULAR FORM CONTROLS + // getStockControl() { + // let formArray = this.employerForm.get('questions') as FormArray; + // // console.log(formArray); + // let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // // console.log(business_group_ctrl); + // let stockCtrl = business_group_ctrl.at(2).get('images') as FormArray + // // console.log("stock",stockCtrl); + // // console.log(this.employerForm.value); + // return stockCtrl.controls + // } + + getPhotoControls(formArrayName) { + let formArray = this.employerForm.get('questions') as FormArray; + // console.log(formArray); + let officeControl = formArray.at(2).get(formArrayName) as FormArray + // console.log(business_group_ctrl); + // let stockCtrl = business_group_ctrl.at(0).get('office_photographs') as FormArray + // console.log("stock",stockCtrl); + // console.log(this.employerForm.value); + return officeControl.controls + } + + // getBusinessAssetSightImage() { + // let formArray = this.employerForm.get('questions') as FormArray; + // // console.log(formArray); + // let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // // console.log(business_group_ctrl); + // let stockCtrl = business_group_ctrl.at(1).get('business_sight_image') as FormArray + // // console.log("stock",stockCtrl); + // // console.log(this.employerForm.value); + // return stockCtrl.controls + // } + // getBusinessInfoDocsControl() { + // let formArray = this.employerForm.get('questions') as FormArray; + // // console.log(formArray); + // let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // // console.log(business_group_ctrl); + // let docsCtrl = business_group_ctrl.at(0).get('documents_info') as FormArray + // // console.log("stock",docsCtrl); + // // console.log(this.employerForm.value); + // return docsCtrl.controls + // } + // getBusinessInfoOtherDocsControl() { + // let formArray = this.employerForm.get('questions') as FormArray; + // // console.log(formArray); + // let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // // console.log(business_group_ctrl); + // let docsCtrl = business_group_ctrl.at(0).get('other_documents_info') as FormArray + // // console.log("stock",docsCtrl); + // // console.log(this.employerForm.value); + // return docsCtrl.controls + // } + // getBusinessInfoControls() { + // let formArray = this.employerForm.get('questions') as FormArray; + // // console.log(formArray); + // let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // // console.log(business_group_ctrl); + // return business_group_ctrl + // } + // getNeibhourControl() { + // let formArray = this.employerForm.get('questions') as FormArray; + // // console.log(formArray); + // let neighbourCtrl = formArray.at(3).get('neighbourhood_list') as FormArray + // // console.log(neighbourCtrl); + // return neighbourCtrl.controls + // } + getQuestionControl() { + let formArray = this.employerForm.get('questions') as FormArray; + // console.log(formArray); + return formArray + } + // END OF GETTING PARTICULAR FORM CONTROLS + + //START OF ADD OR REMOVE MORE FORMS OR IMAGES + // addMoreStockImage(form_id?) { + // let formArray = this.employerForm.get('questions') as FormArray; + // // console.log(formArray); + // let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // // console.log(business_group_ctrl); + // let stockCtrl = business_group_ctrl.at(2).get('images') as FormArray + // // console.log("stock",stockCtrl); + // // stockCtrl.push(this.addStockImageControl()) + // if(form_id) { + // this.capturePic(stockCtrl,'stock_image ',form_id) + // } + // else { + // stockCtrl.push(this.addImageControl()) + // // stockCtrl = stockCtrl.at(stockCtrl.length-1)['controls'].image + // } + // // console.log(this.employerForm.value); + // } + addMoreImage(formArrayName,form_id?) { + let formArray = this.employerForm.get('questions') as FormArray; + // console.log(formArray); + let officeControl = formArray.at(2).get(formArrayName) as FormArray + // console.log(business_group_ctrl); + // let officeControl = business_group_ctrl.at(0).get('office_photographs') as FormArray + // console.log("stock",stockCtrl); + // stockCtrl.push(this.addStockImageControl()) + if(form_id) { + // this.capturePic(officeControl,formArrayName,form_id) + } + else { + officeControl.push(this.addImageControl()) + // stockCtrl = stockCtrl.at(stockCtrl.length-1)['controls'].image + } + // console.log(this.employerForm.value); + } + // addMoreBusinessAssetSightImage(form_id?) { + // let formArray = this.employerForm.get('questions') as FormArray; + // // console.log(formArray); + // let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // // console.log(business_group_ctrl); + // let stockCtrl = business_group_ctrl.at(1).get('business_sight_image') as FormArray + // // console.log("stock",stockCtrl); + // // stockCtrl.push(this.addStockImageControl()) + // if(form_id) { + // this.capturePic(stockCtrl,'business_sight_image ',form_id) + // } + // else { + // stockCtrl.push(this.addImageControl()) + // // stockCtrl = stockCtrl.at(stockCtrl.length-1)['controls'].image + // } + // // console.log(this.employerForm.value); + // } + + addGeneralIndividualsGroup() { + let formArray = this.employerForm.get('questions') as FormArray; + let individualCtrl = formArray.at(0).get('individuals') as FormArray + if(this.applicants.length > 0) + { + this.applicants.forEach(applicant_obj=>{ + individualCtrl.push(this.addGeneralIndividualControls(applicant_obj)) + }) + } + } + + // addNeighbourhoodGroup() { + // let formArray = this.employerForm.get('questions') as FormArray; + // // console.log(formArray); + // let neighbourCtrl = formArray.at(3).get('neighbourhood_list') as FormArray + // // console.log(neighbourCtrl); + // neighbourCtrl.push(this.addNeighbourListControls()) + // this.matExpanded= neighbourCtrl.length-1 + // } + + removeneighbourhoodGroup(index) { + let formArray = this.employerForm.get('questions') as FormArray; + // console.log(formArray); + let neighbourCtrl = formArray.at(3).get('neighbourhood_list') as FormArray + // console.log(neighbourCtrl); + if(neighbourCtrl.length==1) + { + neighbourCtrl.reset(); + }else{ + neighbourCtrl.removeAt(index); + this.matExpanded = neighbourCtrl.length-1 + } + } + // addDocumentsGroup( ) { + // let formArray = this.employerForm.get('questions') as FormArray; + // // console.log(formArray); + // let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // // console.log(business_group_ctrl); + // let docsCtrl = business_group_ctrl.at(0).get('documents_info') as FormArray + // docsCtrl.push(this.addBusinessInfoDocsControls()) + // } + + // removeDocumentsGroup(index) { + // let formArray = this.employerForm.get('questions') as FormArray; + // // console.log(formArray); + // let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // // console.log(business_group_ctrl); + // let docsCtrl = business_group_ctrl.at(0).get('documents_info') as FormArray + // if(docsCtrl.length==1) + // { + // docsCtrl.reset(); + // }else{ + // docsCtrl.removeAt(index); + // } + // } + // addOtherDocumentsGroup( ) { + // let formArray = this.employerForm.get('questions') as FormArray; + // // console.log(formArray); + // let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // // console.log(business_group_ctrl); + // let docsCtrl = business_group_ctrl.at(0).get('other_documents_info') as FormArray + // docsCtrl.push(this.addBusinessInfoOtherDocsControls()) + // } + + // removeOtherDocumentsGroup(index) { + // let formArray = this.employerForm.get('questions') as FormArray; + // // console.log(formArray); + // let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // // console.log(business_group_ctrl); + // let docsCtrl = business_group_ctrl.at(0).get('other_documents_info') as FormArray + // if(docsCtrl.length==1) + // { + // docsCtrl.reset(); + // }else{ + // docsCtrl.removeAt(index); + // } + // } + //END OF ADD OR REMOVE MORE FORMS OR IMAGES + + toggleVisibility(e,index,flag){ + let val + + if(flag == 1){ + this.isDisplay[index] = e; + } + else if(flag==2){ + this.isDisplay2[index] = e; + } + } + getOtherOrganisationOwner(value,i) { + //console.log('value',value,'I',i); + let formArray = this.employerForm.get('questions') as FormArray; + // console.log(formArray); + let Ctrls = formArray.at(3).get('neighbourhood_list') as FormArray + // console.log(Ctrls); + //console.log('ParCtrls',Ctrls); + let ChdCtrls:any = Ctrls.controls[i]; + // console.log('ChdCtrls',ChdCtrls); + // return; + + + let Avaliablity = 1; + // console.log('val',value); + if(value.length>0){ + value.forEach(option => { + if(option.id == 0 && option.group_id == 2){ + Avaliablity = option.id; + } + }); + } + if(Avaliablity == 0){ + // console.log('if Avaliablity',Avaliablity); + + ChdCtrls.controls.other_organisation_owner.setValidators([Validators.required]); + this.isOrganisationOwner[i] = true; + }else if(Avaliablity == 1){ + // console.log('else Avaliablity',Avaliablity); + // console.log('esle this.isOrganisationOwner[ParInx]',this.isOrganisationOwner[i]); + ChdCtrls.controls.other_organisation_owner.setValue(''); + ChdCtrls.controls.other_organisation_owner.clearValidators(); + this.isOrganisationOwner[i] = false; + // console.log('else this.isOrganisationOwner[ParInx]',this.isOrganisationOwner[i]); + } + + ChdCtrls.controls.other_organisation_owner.updateValueAndValidity(); + } + + // capturePic(controls,img_name?:String,form_id?) { + // console.clear(); + // console.log(controls) + // // return; + // // controls.setValue("pic"); + + // // this.cameraProvider.getpicture().then(res => { + // this.cameraProvider.showImageDialog().then((res:any)=>{ + // console.log("g",res) + // if (res != 'error') { + // let geoCoordinates = localStorage.getItem('current_coordinates') + // // this.cons.getGeoTag().then(geoCoordinates=>{ + // this.cameraProvider.addWatermarks(res).then(watermarkedImage => { + // console.log("image name",img_name,img_name === 'office_photograph ') + // if(img_name == 'nameboard_photographs' || img_name == 'office_photographs') { + // console.log("Before") + // controls.push(this.addImageControl()) + // console.log("after") + // img_name = img_name+String(controls.length) + // controls = controls.at(controls.length-1)['controls'].image + // } + // console.log("controls",controls); + // controls.setValue(watermarkedImage) + // let bucket: any = [] + // bucket.push({ 'image': watermarkedImage, 'Name': img_name, 'link': geoCoordinates }); + // let records: any = { + // 'pd_id': this.pdDetails.pd_id, + // 'formid': form_id, + // 'images': bucket, + // 'company_id': null, + // } + // // For Business Groups + // if(form_id == '11' || form_id == '13' || form_id == '22') { + // records.company_id = '1' + // } + // console.log("params savePDImage", records) + // this.quesService.savePDImages(records).subscribe(result => { + // if(result['dataStatus']) { + // if(img_name == 'Person Met Pic') { + // this.sendGeoCords(geoCoordinates) + // } + // controls.setValue(result['uri']) + // } + // else { + // console.log(result); + // controls.setValue("") + // this.toastProvider.pdTriggerappmessage("Something went wrong!!",'warning'); + // } + // },err=>{ + // controls.setValue("") + // console.log(err) + // this.toastProvider.pdTriggerappmessage("Network Error","danger") + // }) + // }) + // } + // }) + // } + // sendGeoCords(location) { + // let params = {"pd_id":this.pdDetails.pd_id,"geo_location":location,"comment":"","fk_updatedby":this.users} + // this.quesService.renewSatellite(params).subscribe(rr=>{ + + // }) + // } + compareObjects(o1: any, o2: any) { + if(o1.id == o2.id && o1.group_id == o2.group_id) + return true; + else return false + } + + ConvertMonthintoYearOnNeighbour(itemrow,e,flag){ + if(flag == 2){ + + let year = itemrow.controls.year_relation_applicant.value; + let converted_month : number = e%12; + let converted_year : number = e/12; + itemrow.controls.year_relation_applicant.setValue(+year + +Math.floor(converted_year)); + itemrow.controls.months_relation_applicant.setValue(Math.floor(converted_month)); + } + else if(flag == 1){ + + let year = itemrow.controls.company_existence_years.value; + let converted_month : number = e%12; + let converted_year : number = e/12; + itemrow.controls.company_existence_years.setValue(+year + +Math.floor(converted_year)); + itemrow.controls.company_existence_months.setValue(Math.floor(converted_month)); + } + } + // onDocsSightedChange(value,flag) { + // // 1 - Documents sighted + // // 2 - Other Documents + + // let formArrayName = 'documents_info' + // if(flag != 1) { + // formArrayName = 'other_documents_info' + // } + // if(value == 'yes') { + // if(flag == 1) { + // this.addDocumentsGroup() + // } + // else { + // this.addOtherDocumentsGroup(); + // formArrayName = 'other_documents_info' + // } + // } + // else { + + // let formArray = this.employerForm.get('questions') as FormArray; + // let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // let docsCtrl = business_group_ctrl.at(0).get(formArrayName) as FormArray + // while(docsCtrl.length !== 0) { + // docsCtrl.removeAt(0) + // } + // } + // } + + // saveApplicantInfo(applicant_obj,image_key) { + // console.log(applicant_obj); + // this.cameraProvider.showImageDialog().then((res:any)=>{ + // console.log("g",res) + // if (res != 'error') { + // let geoCoordinates = localStorage.getItem('current_coordinates') + // // this.cons.getGeoTag().then(geoCoordinates=>{ + // this.cameraProvider.addWatermarks(res).then(watermarkedImage => { + // applicant_obj.controls[image_key].setValue(watermarkedImage); + // let params = { + // "pd_co_applicant_id":applicant_obj.value.pd_co_applicant_id, + // "applicant_name":applicant_obj.value.applicant_name, + // "is_person_met":applicant_obj.value.is_person_met, + // "fk_pd_id":this.pdDetails.pd_id, + // "link":geoCoordinates + // } + // params[image_key] = applicant_obj.value[image_key] + + // this.quesService.saveApplicantImgFromVendorForm(params).subscribe(result=>{ + // if(result['dataStatus']) { + // this.sendGeoCords(geoCoordinates) + // applicant_obj.controls[image_key].setValue(result['uri']); + // } + // else { + // applicant_obj.controls[image_key].setValue(""); + // console.log(result); + // this.toastProvider.pdTriggerappmessage("Something went wrong!!",'warning'); + // } + // },err=>{ + // applicant_obj.controls[image_key].setValue(""); + // console.log(err) + // this.toastProvider.pdTriggerappmessage("Network Error","danger") + // }) + // }) + // } + // }) + // } + public findInvalidControls() { + const invalid = []; + let msg='' + let formArray = this.employerForm.get('questions') as FormArray; + console.log(formArray); + for( const group of formArray['controls']) { + if(group.invalid) { + console.log(group,group.value.form_name); + // debugger; + msg= "Questions are not filled up in "+group.value.form_name + let index = this.stepperInfo.findIndex(vv=>vv.form_id == group.value.form_id); + console.log("Index",index); + if(index != -1) { + msg = "Questions are not filled up in "+this.stepperInfo[index].form_name + this.myStepper.selectedIndex = this.stepperInfo[index].stepper_index + } + for (const name in group['controls']) { + if (group['controls'][name].invalid) { + invalid.push(name); + let invalidFields = [].slice.call(document.getElementsByClassName('ng-invalid')); + let firstInvalidField; + for(let val in invalidFields){ + if( invalidFields[val].nodeName == 'MAT-FORM-FIELD' || invalidFields[val].nodeName == 'MAT-SELECT' || invalidFields[val].nodeName == 'TEXTAREA' ){ //INPUT FOR INPUT FIELD + firstInvalidField=invalidFields[val] + break; + } + } + if(firstInvalidField != undefined){ + firstInvalidField.scrollIntoView({behavior: "smooth", block: "end", inline: "nearest"}) + // this.myStepper.selectedIndex = 0; + + } + + console.log("kkdd",group['controls'][name],firstInvalidField) + + // if(typeof(group['controls'][name].value) == 'string') { + // return name+' field is not ' + // } + break + } + } + break; + } + } + // let business_group_ctrl = formArray.at(2).get('business_group') as FormArray + // const controls = this.getQuestionControl().at(1)['controls'] + // for (const name in controls) { + // if (controls[name].invalid) { + // invalid.push(name); + // } + // } + return msg; + } + // public findInvalidControls() { + // const controls = this.quesAnsForm.get('questions')['controls']; + // console.log(controls) + // for (const name in controls) { + // if (controls[name].invalid) { + // let invalidFields = [].slice.call(document.getElementsByClassName('ng-invalid')); + // let firstInvalidField; + // for(let val in invalidFields){ + // if( invalidFields[val].nodeName == 'MAT-FORM-FIELD'){ //INPUT FOR INPUT FIELD + // firstInvalidField=invalidFields[val] + // break; + // } + // } + // if(firstInvalidField != undefined){ + // firstInvalidField.scrollIntoView(true) + // } + // break; + // } + // } + // // return invalid; + // } + onSubmit(flag?) { + if(this.spinner_access) { + this.notifier.notify("info","Form processing please wait..."); + return; + } + if(this.employerForm.invalid && flag != 'go_back') { + console.log('form value',this.employerForm.getRawValue()) + let invalidMsg = "Please Fill all the required fields and capture the image" + let tempMsg = this.findInvalidControls() + if(tempMsg != '') { + invalidMsg =tempMsg + } + this.notifier.notify("warning",invalidMsg); + return + } + + // return; + + let records= this.employerForm.getRawValue() + // FOR VERFYING THE IMAGE ARE CAPTURED + // if(flag != 'go_back') { + // let photCheck=records.questions[2] + // let index = this.stepperInfo.findIndex(vv=>vv.form_id == photCheck.form_id); + // console.log("Index",index); + + // if(photCheck.hasOwnProperty('nameboard_photographs') && photCheck.nameboard_photographs.length <1) { + // if(index != -1) { + // this.myStepper.selectedIndex = this.stepperInfo[index].stepper_index + // } + // console.log("asdf"); + // this.notifier.notify("info","Minimum 1 photo required on Name Board") + // return + // } + // if(photCheck.hasOwnProperty('office_photographs') && photCheck.office_photographs.length <3) { + // if(index != -1) { + // this.myStepper.selectedIndex = this.stepperInfo[index].stepper_index + // } + // this.notifier.notify("info","Minimum 3 photos required on Office Setup") + // return + // } + // } + this.spinner_access = true; + console.log(records); + records.pdid = this.pdDetails.pd_id; + records.formid = "25"; + records.fk_createdby = this.users; + this.quesService.savePDFormDetailsWithID(records).subscribe(result=>{ + if(result['dataStatus']) { + if(flag != 'go_back') { + this.notifier.notify('success',"Saved Successfully..."); + } + this.employerForm.markAsPristine(); + this.employerForm.markAsUntouched(); + if(flag != 'go_back') { + setTimeout(()=>{ + this.dialogRef.close() + },3000) + } + } + else { + this.notifier.notify('info',"Something went wrong"); + } + this.spinner_access = false + },err=>{ + console.log("Error in savePDFormDetails",err); + this.notifier.notify('info',"Network Error"); + this.spinner_access = false + }) + } + + // FOR CHECKING THE UNSAVED CHANGES + + countRowsForTextarea(text){ + + + + if(text !='' && text != undefined){ + if(text.length%100 > 5) + return 5; + else if(text.length%100 <= 3) + return 3; + else return Math.floor(text.length%100); + + } + } + searchFun(control:any,i:number,option,flag){ + if(flag == 1) { + console.log(control,this.getQuestionControl().at(1)); + control = this.getQuestionControl().at(1) + } + if (option == 'city' && flag ==1) { + control.controls['citySearch'].valueChanges + .pipe(takeUntil(this._onDestroy)) + .subscribe(() => { + this.SearchCity(control.controls['citySearch'].value, i); + }) + } + if (option == 'state') { + + control.controls['stateSearch'].valueChanges + .pipe(takeUntil(this._onDestroy)) + .subscribe(()=>{ + this.searchState(control.controls['stateSearch'].value) + }) + } + if (option == 'pin' && flag ==1) { + + control.controls['pinSearch'].valueChanges + .pipe(takeUntil(this._onDestroy)) + .subscribe(()=>{ + this.searchPin(control.controls['pinSearch'].value,i) + }) + } + if (option == 'city' && flag ==2) { + control.controls['citySearch'].valueChanges + .pipe(takeUntil(this._onDestroy)) + .subscribe(() => { + this.SearchAlternativeCity(control.controls['citySearch'].value, i); + }) + } + if (option == 'pin' && flag ==2) { + + control.controls['pinSearch'].valueChanges + .pipe(takeUntil(this._onDestroy)) + .subscribe(()=>{ + this.searchAlternativePin(control.controls['pinSearch'].value,i) + }) + } + } + searchPin(val:any,index:number){ + if(!this.pincodeData[index]){ + return + } + let searchValue=val + if(!searchValue){ + this.pincodeDataValue[index]=this.pincodeData[index].slice() + return + }else{ + searchValue=searchValue.toLowerCase() + } + this.pincodeDataValue[index]=this.pincodeData[index].filter(value=>value.pincode.toLowerCase().indexOf(searchValue) > -1) + } + SearchCity(val: any, i: number) { + if (!this.cityData[i]) { + return + } + let searchValue = val + if (!searchValue) { + // this.filteredCity.next(this.cityData[i].slice()) + this.cityDataValue[i]=this.cityData[i].slice() + return + } else { + searchValue = searchValue.toLowerCase() + } + this.cityDataValue[i]=this.cityData[i].filter(value => value.city_name.toLowerCase().indexOf(searchValue) > -1) + // this.filteredCity.next( + // this.cityData[i].filter(value => value.city_name.toLowerCase().indexOf(searchValue) > -1) + // ) + + } + searchAlternativePin(val:any,index:number){ + if(!this.pincodeData[index]){ + return + } + let searchValue=val + if(!searchValue){ + this.alertnativePincodeData[index]=this.pincodeData[index].slice() + return + }else{ + searchValue=searchValue.toLowerCase() + } + this.alertnativePincodeData[index]=this.pincodeData[index].filter(value=>value.pincode.toLowerCase().indexOf(searchValue) > -1) + } + SearchAlternativeCity(val: any, i: number) { + if (!this.cityData[i]) { + return + } + let searchValue = val + if (!searchValue) { + // this.filteredCity.next(this.cityData[i].slice()) + this.alertnativeCityData[i]=this.cityData[i].slice() + return + } else { + searchValue = searchValue.toLowerCase() + } + this.alertnativeCityData[i]=this.cityData[i].filter(value => value.city_name.toLowerCase().indexOf(searchValue) > -1) + // this.filteredCity.next( + // this.cityData[i].filter(value => value.city_name.toLowerCase().indexOf(searchValue) > -1) + // ) + + } + searchState(val: any) { + + if (!this.stateData) { + return + } + let searchVal = val + if (!searchVal) { + this.filteredState.next(this.stateData.slice()) + return + } + else { + searchVal = searchVal.toLowerCase() + } + this.filteredState.next( + this.stateData.filter(res => res.name.toLowerCase().indexOf(searchVal) > -1) + ) + } + selectedAddressType(e: any) { + this.placeholderName = 'Estimated area of the ' + e; + } + + setValidationForRemarks(value_neighbourhood_status) { + let control= this.getQuestionControl().at(3)['controls']['neighbour_reference_remark'] + console.log(value_neighbourhood_status,control) + if(value_neighbourhood_status == 'Could not verify' || value_neighbourhood_status == 'Negative') { + control.setValidators(Validators.required) + } + else { + control.clearValidators() + } + control.updateValueAndValidity(); + } + + // FOR HANDLING ALL TYPE OF ON CHANGE + checkPartEnable(flag) { + let general_controls = this.getQuestionControl().at(0)['controls'] + let employement_controls:any = this.getQuestionControl().at(2) + let applicant_arr = this.getQuestionControl().at(0).get('individuals').value + let return_value = '' + switch (flag) { + // FOR PERSON MET ENETERED MANUAL FIELDS + case 1: + if(general_controls.is_met_during_visit.value != 'yes') { + general_controls.person_met_entered.setValue('') + general_controls.person_met_entered_pic.setValue('') + general_controls.person_met_entered.clearValidators(); + general_controls.person_met_entered_pic.clearValidators(); + } + if(general_controls.is_met_during_visit.value == '') { + employement_controls.removeControl('nameboard_photographs') + employement_controls.removeControl('office_photographs') + } + if (general_controls.is_met_during_visit.value == 'yes') { + general_controls.person_met_entered.setValidators(Validators.required); + // general_controls.person_met_entered_pic.setValidators(Validators.required); + // FOR ADDING OFFICE PHOTO + employement_controls.addControl('office_photographs',this._formBuilder.array([])) + // FOR REMOVING NAME BOARD PHOTO + employement_controls.removeControl('nameboard_photographs') + return true + } + else if(general_controls.is_met_during_visit.value == 'no'){ + // FOR ADDING NAME BOARD PHOTO + employement_controls.addControl('nameboard_photographs',this._formBuilder.array([])) + // FOR REMOVING OFFICE PHOTO + employement_controls.removeControl('office_photographs') + return false + } + + break; + // FOR is_met_during_visit FIELD + case 2: + if(applicant_arr && applicant_arr.length > 0) { + if(applicant_arr.filter(vv=>vv.is_person_met == true).length == 0 && general_controls.is_employer_available.value == 'no') { + general_controls.is_met_during_visit.setValidators(Validators.required); + return true + } + else{ + general_controls.is_met_during_visit.setValue('') + general_controls.is_met_during_visit.clearValidators(); + return false + } + } + break; + // FOR THE QUESTION WHY NO DOCUMENTS TO BE SIGHTED REASON + case 3: + if(!this.getDocsSightedGroup) { return false} + let ctrl_values=this.getDocsSightedGroup['value'] + if(ctrl_values.sal_reg_seen == 'no' && ctrl_values.attendance_seen == 'no' && ctrl_values.cash_voucher == 'no' && ctrl_values.sal_certificate == 'no' && ctrl_values.sal_slip == 'no' && ctrl_values.other_doc == 'no') { + this.getDocsSightedGroup['controls'].doc_not_available.setValidators(Validators.required); + return true; + } + else { + this.getDocsSightedGroup['controls'].doc_not_available.setValue('') + this.getDocsSightedGroup['controls'].doc_not_available.clearValidators(); + return false + } + break; + // FOR ENABLING EMPLOYMENT INFOMATION SECTIONS + case 4: + if (general_controls.is_employer_available.value == 'yes') { + employement_controls.addControl('employer_details',this.getEmployerDetailsControls()) + return true; + } + else{ + employement_controls.removeControl('employer_details') + return false; + } + // FOR ENABLING DOCUMENT SIGHTED + case 5: + // let applicant_arr = this.getQuestionControl().at(0).get('individuals').value + // console.log(applicant_arr) + if(applicant_arr && applicant_arr.length > 0) { + if(general_controls.is_employer_available.value == 'no' && applicant_arr.filter(vv=>vv.is_person_met == true).length != 0 ){ + employement_controls.addControl('docs_sighted',this.getDocsSightedDetailsControls()) + return true; + } + else{ + employement_controls.removeControl('docs_sighted') + return false + } + } + return false + break; + } + this.employerForm.updateValueAndValidity(); + // return return_value + } + + + // canDeactivate(){ + // // this.timer.unsubscribe(); + // // console.log(this.employerForm.dirty) + // // if(this.employerForm.dirty){ + // // this.onSubmit('go_back'); + // // // return this.constant.chekAlertOnLeave().then(res=>{ + // // // console.log(res) + // // // return res + // // // }) + // // return true; + // // } + // // else{ + // return true + // // } + // } + ngOnDestroy() { + if(this.employerForm.dirty){ + this.onSubmit('go_back'); + } + } + + + formDate(value){ + // console.log('to',this.todate) + // console.log(value); + // console.log('to length',this.todate.length); + // console.log('index',value-1); + // console.log('this.todate',this.todate[11]); + // console.log('this.todate',this.todate[11].isdisabled); + this.getEmployer_details['controls']['to_date_the_salary_is_rcv'].setValue(''); + this.todate = [{date:1,isdisabled:false},{date:2,isdisabled:false},{date:3,isdisabled:false},{date:4,isdisabled:false},{date:5,isdisabled:false},{date:6,isdisabled:false},{date:7,isdisabled:false},{date:8,isdisabled:false},{date:9,isdisabled:false},{date:10,isdisabled:false},{date:11,isdisabled:false},{date:12,isdisabled:false},{date:13,isdisabled:false},{date:14,isdisabled:false},{date:15,isdisabled:false},{date:16,isdisabled:false},{date:17,isdisabled:false},{date:18,isdisabled:false},{date:19,isdisabled:false},{date:20,isdisabled:false},{date:21,isdisabled:false},{date:22,isdisabled:false},{date:23,isdisabled:false},{date:24,isdisabled:false},{date:25,isdisabled:false},{date:26,isdisabled:false},{date:27,isdisabled:false},{date:28,isdisabled:false},{date:29,isdisabled:false},{date:30,isdisabled:false},{date:31,isdisabled:false}]; + var i ; + + if(value != 0 && value != '') + for(i=0;i<=value-1;i++){ + this.todate[i].isdisabled = true; + if(value == 31){ + this.todate[30].isdisabled = false; + } + } + + } + + ValidateNetSalary(){ + let salary = this.getEmployer_details['controls']['net_monthly_salary'].value; + // console.log('this.employer_details['controls'][amount_paid_in_cash].value',this.getEmployer_details['controls']['amount_paid_in_cash'].value); + + if(salary != ''){ + // let cash_amount = this.getEmployer_details['controls']['amount_paid_in_cash'].value; + let bank_amount = this.getEmployer_details['controls']['amount_paid_through_bank'].value; + + this.getEmployer_details['controls']['amount_paid_through_bank'].setValidators([Validators.max(salary),Validators.min(0)]); + this.getEmployer_details['controls']['amount_paid_through_bank'].updateValueAndValidity(); + let Remainamt = salary-bank_amount + if(Remainamt >= 0 ){ + this.getEmployer_details['controls']['amount_paid_in_cash'].setValue(Remainamt); + this.getEmployer_details['controls']['amount_paid_in_cash'].setValidators([Validators.max(salary-bank_amount),Validators.min(salary-bank_amount)]); + } + else{ + this.getEmployer_details['controls']['amount_paid_in_cash'].setValue('0'); + this.getEmployer_details['controls']['amount_paid_in_cash'].setValidators([Validators.max(0),Validators.min(0)]); + } + this.getEmployer_details['controls']['amount_paid_in_cash'].updateValueAndValidity(); + + } + else{ + this.notifier.notify('info','Net Monthly Salary Is Empty.!'); + // this.t.notify('warning', 'Net Monthly Salary Is Empty.!'); + this.getEmployer_details['controls']['amount_paid_in_cash'].setValue(''); + // this.getEmployer_details['controls']['amount_paid_in_cash'].clearValidators(); + this.getEmployer_details['controls']['amount_paid_in_cash'].updateValueAndValidity(); + this.getEmployer_details['controls']['amount_paid_through_bank'].setValue(''); + // this.getEmployer_details['controls']['amount_paid_through_bank'].clearValidators(); + this.getEmployer_details['controls']['amount_paid_through_bank'].updateValueAndValidity(); + return; + } + + + } + checkSpecifyField(value) { + // let field=this.getBusinessInfoControls().at(1)['controls']['business_is_pd_visited_yes'].value + // console.log(field); + if(value && value.filter(vv=>vv.includes('Others')).length > 0) { + return true + } + return false + } +} diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/pd-questions-routing.module.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/pd-questions-routing.module.ts new file mode 100644 index 0000000..9ec62ca --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/pd-questions-routing.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import { CommonQuesComponent } from './common-ques/common-ques.component'; + +const routes: Routes = [ + { + path:'', + component:CommonQuesComponent + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class PdQuestionsRoutingModule { } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/pd-questions.module.spec.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/pd-questions.module.spec.ts new file mode 100644 index 0000000..7f248f3 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/pd-questions.module.spec.ts @@ -0,0 +1,13 @@ +import { PdQuestionsModule } from './pd-questions.module'; + +describe('PdQuestionsModule', () => { + let pdQuestionsModule: PdQuestionsModule; + + beforeEach(() => { + pdQuestionsModule = new PdQuestionsModule(); + }); + + it('should create an instance', () => { + expect(pdQuestionsModule).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/pd-questions.module.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/pd-questions.module.ts new file mode 100644 index 0000000..33041af --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-questions/pd-questions.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { PdQuestionsRoutingModule } from './pd-questions-routing.module'; +import { CommonQuesComponent } from './common-ques/common-ques.component'; +import { EmployerInfoComponent } from './employer-info/employer-info.component'; +import { DynamicDocsFormComponent } from './dynamic-docs-form/dynamic-docs-form.component'; + +@NgModule({ + imports: [ + CommonModule, + PdQuestionsRoutingModule + ], + declarations: [] +}) +export class PdQuestionsModule { } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-status-change-dialogue/pd-status-change-dialogue.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-status-change-dialogue/pd-status-change-dialogue.component.ts index 4353ad6..c07b0b2 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-status-change-dialogue/pd-status-change-dialogue.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-status-change-dialogue/pd-status-change-dialogue.component.ts @@ -60,8 +60,9 @@ export class PdStatusChangeDialogueComponent implements OnInit { changePDStatus(status: string): void { let update_status = { "pd_id":this.data.pdid, + "vendor_status":status }; - this.pd.editPdMasterDetails(update_status, status).subscribe(result => { + this.pd.updatePdOfficer(update_status).subscribe(result => { if (result.status == 200) { this.dialogRef.close({update_status:true}); this.notifier.notify('success', this.data.vendor_status=='INPROGRESS' ? 'Discussions Started Successfully' : this.data.vendor_status=='COMPLETED' ? 'Discussions Completed Successfully' : 'Discussions Updated Successfully'); 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 3a25028..a386527 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 @@ -152,14 +152,15 @@ +
-
- {{master.pd_allocated_to | titlecase}} +
+ {{master.vendor_pdofficer_name | titlecase}}
{{master.executive_name | titlecase}} @@ -192,13 +193,13 @@
- +
-
- {{addresses.addtional_pd_data[0].pd_allocated_to | titlecase}} +
+ {{addresses.addtional_pd_data[0].vendor_pdofficer_name | titlecase}}
{{addresses.addtional_pd_data[0].executive_name | titlecase}} @@ -414,4 +415,4 @@ - \ No newline at end of file + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.ts index 5f1a5ca..b459b67 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.ts @@ -18,6 +18,8 @@ import { InitiateAdditionalPdComponent } from './../initiate-additional-pd/initi /**sweet alert */ import Swal from 'sweetalert2'; import { SchedulePdComponent } from '../schedule-pd/schedule-pd.component'; +import { CommonQuesComponent } from '../pd-questions/common-ques/common-ques.component'; +import { EmployerInfoComponent } from '../pd-questions/employer-info/employer-info.component'; @Component({ selector: 'app-view-pd', @@ -367,14 +369,42 @@ export class ViewPdComponent implements OnInit, OnDestroy { dialogRef.afterClosed() .subscribe(dataresult => { if (dataresult.update_status == true) { - this.router.navigate(['../../startpd',pdDetails.assigned_pd], { relativeTo: this.route }); + // this.router.navigate(['../../startpd',pdDetails.assigned_pd], { relativeTo: this.route }); + this.openQuesComp(pdDetails) } }); } else { - this.router.navigate(['../../startpd', pdDetails.assigned_pd], { relativeTo: this.route }); + this.openQuesComp(pdDetails) + + // this._pd.pdQuestionMasterData = temp; + // this.router.navigate(['../../../pd-questions', pdDetails.assigned_pd,this.masterRandomString], {relativeTo: this.route }); + } } + openQuesComp(pdDetails) { + let quesComponent:any = CommonQuesComponent + if(this.CustomerSegmentAbbr == 'SAL') { + quesComponent = EmployerInfoComponent + } + let temp:any = pdDetails.addtional_pd_data[0] + temp.applicants_details = this.pdApplicantData + temp.docs_collected = this.pdCollectedDocument + const dialogRef = this.dialog.open(quesComponent, { + data: temp, + // position: { right: '0'}, + maxWidth: '100vw', + maxHeight: '100vh', + height: '100%', + width: '100%', + disableClose: true + }); + dialogRef.afterClosed() + .subscribe(dataresult => { + // this.notifier.notify('success', 'Successfully allocated.!'); + // this.loadTemplates(this.startPD,2,this.randomString); + }); + } getPDIDReport(pdID: any) { this.destroyType = 3; diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts b/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts index bbb75fb..ebe1480 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts @@ -123,6 +123,9 @@ import { GetAnswerableFormsPipe } from './../pd-pipes/get-answerable-forms.pipe' // import { FuturePlansAndBusinessEnvironmentComponent } from './list-pd/start-pd/forms/future-plans-and-business-environment/future-plans-and-business-environment.component'; // import { ImageCropComponent } from './list-pd/start-pd/forms/dialogue/image-crop/image-crop.component'; import {AngularSplitModule} from 'angular-split' +import { CommonQuesComponent } from './list-pd/pd-questions/common-ques/common-ques.component'; +import { EmployerInfoComponent } from './list-pd/pd-questions/employer-info/employer-info.component'; +import { DynamicDocsFormComponent } from './list-pd/pd-questions/dynamic-docs-form/dynamic-docs-form.component'; /** * Custom angular notifier options @@ -169,7 +172,9 @@ const pdCustomNotifierOptions: NotifierOptions = { }; @NgModule({ - declarations: [SchedulePdComponent,PdAllocationComponent,TelePdAllocationComponent, ListPdComponent, ManagePdComponent, MapPdViewComponent, AddPdComponent, ViewPdComponent, SmartPdAllocationComponent, EditPdApplicantComponent, EditPdMasterComponent, InprogressPdComponent, AllPdComponent, ScheduledPdComponent, CompletedPdComponent, QcCompletedPdComponent, PdReportComponent, PdRequirementComponent, ModelEditPdReportComponent, DialogChangeCurrentVenrsion, QcReviewComponent, SearchRelationPipe, RupeeCurrencyFormatPipe, NumberToWordsPipe, DeleteRecordsCountPipe, PdLocatedMapViewDirective, ViewLocationComponent, GetAnswerableFormsPipe,PdStatusChangeDialogueComponent,InitiateAdditionalPdComponent], + declarations: [SchedulePdComponent,PdAllocationComponent,TelePdAllocationComponent, ListPdComponent, ManagePdComponent, MapPdViewComponent, AddPdComponent, ViewPdComponent, SmartPdAllocationComponent, EditPdApplicantComponent, EditPdMasterComponent, InprogressPdComponent, AllPdComponent, ScheduledPdComponent, CompletedPdComponent, QcCompletedPdComponent, PdReportComponent, PdRequirementComponent, ModelEditPdReportComponent, DialogChangeCurrentVenrsion, QcReviewComponent, SearchRelationPipe, RupeeCurrencyFormatPipe, NumberToWordsPipe, DeleteRecordsCountPipe, PdLocatedMapViewDirective, ViewLocationComponent, GetAnswerableFormsPipe,PdStatusChangeDialogueComponent,InitiateAdditionalPdComponent, + CommonQuesComponent,EmployerInfoComponent,DynamicDocsFormComponent + ], imports: [ CommonModule, ManagePdRoutingModule, @@ -209,7 +214,8 @@ const pdCustomNotifierOptions: NotifierOptions = { {provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]}, {provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS}, PdLocatedMapViewDirective], - entryComponents: [SchedulePdComponent,PdAllocationComponent,SmartPdAllocationComponent, EditPdApplicantComponent, EditPdMasterComponent, TelePdAllocationComponent, PdRequirementComponent, ModelEditPdReportComponent, DialogChangeCurrentVenrsion, QcReviewComponent, ViewLocationComponent,PdStatusChangeDialogueComponent,InitiateAdditionalPdComponent], + entryComponents: [SchedulePdComponent,PdAllocationComponent,SmartPdAllocationComponent, EditPdApplicantComponent, EditPdMasterComponent, TelePdAllocationComponent, PdRequirementComponent, ModelEditPdReportComponent, DialogChangeCurrentVenrsion, QcReviewComponent, ViewLocationComponent,PdStatusChangeDialogueComponent,InitiateAdditionalPdComponent, + CommonQuesComponent,EmployerInfoComponent], }) export class ManagePdModule { } \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.routing.ts b/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.routing.ts index 0767e1d..1115efc 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.routing.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.routing.ts @@ -6,6 +6,8 @@ import { MapPdViewComponent } from './list-pd/map-pd-view/map-pd-view.component' import { AddPdComponent } from '../manage-pd/list-pd/add-pd/add-pd.component'; import { ViewPdComponent } from '../manage-pd/list-pd/view-pd/view-pd.component'; import { PdReportComponent } from './list-pd/pd-report/pd-report.component'; +import { CommonQuesComponent } from './list-pd/pd-questions/common-ques/common-ques.component'; +import { PdQuestionsModule } from './list-pd/pd-questions/pd-questions.module'; /* * manage pd router */ @@ -37,7 +39,13 @@ const routes: Routes = [ { path: 'pd_report/:pdid/:string', component: PdReportComponent, - } + }, + // { + // path:'pd-questions/:pdid/:string', + // // component:PdQuestionsModule, + // loadChildren:'./list-pd/pd-questions/pd-questions.module#PdQuestionsModule' + // // loadChildren: () => import('./list-pd/pd-questions/pd-questions.module').then( m => m.PdQuestionsModule) + // } ] } ] 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 3e39091..37a63ec 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 @@ -29,6 +29,7 @@ export interface Master { export class PdTrigerService { + pdQuestionMasterData:any=null // private apiUrl = "http://ssa.sineedge.com/sparqapi/api/"; // private apiUrl = "http://192.168.0.5:9999/AWSEC2/sparqapi/api/"; @@ -180,7 +181,7 @@ export class PdTrigerService { if(VendorRoleID == '22'){ console.log('check else',VendorRoleID) vendorParam= userid ? - { params: new HttpParams().set('pdofficerid', userid).set('pdagencyid', ven_id) } : {}; + { params: new HttpParams().set('vendor_pdofficer', userid).set('pdagencyid', ven_id) } : {}; } else { vendorParam= userid ? @@ -209,7 +210,7 @@ export class PdTrigerService { let vendorParam; if(VendorRoleID == '22'){ vendorParam= userid_local && status ? - { params: new HttpParams().set('pdofficerid', userid_local).set('pdagencyid', ven_id).set('status',status) } : {}; + { params: new HttpParams().set('vendor_pdofficer', userid_local).set('pdagencyid', ven_id).set('status',status) } : {}; } else { vendorParam= userid_local && status ? @@ -347,12 +348,12 @@ export class PdTrigerService { }; } // common Pd form details get for the Pd Process - // getPDFormDetailsWithID(params: any): Observable { - // return this._http.post(this.apiUrl + "getPDFormDetails", params) - // .pipe( - // catchError(this.handleError('operation', [])) - // ) - // } + getPDFormDetailsWithID(params: any): Observable { + return this._http.post(this.apiUrl + "getPDFormDetails", params) + .pipe( + catchError(this.handleError('operation', [])) + ) + } // common Pd form details get for the Pd Process // getPDFormDetailsWithCompanyID(pdID, formID,companyID): Observable { @@ -363,16 +364,16 @@ export class PdTrigerService { // } // save Pd form details - // savePDFormDetailsWithID(saveData: any): Observable { - // saveData.fk_createdby = this._aws.getlocale(); - // // saveData[0].fk_updatedby = this._aws.getlocale(); - // // saveData[0].updatedon = currentdate; + savePDFormDetailsWithID(saveData: any): Observable { + saveData.fk_createdby = this._aws.getlocale(); + // saveData[0].fk_updatedby = this._aws.getlocale(); + // saveData[0].updatedon = currentdate; - // return this._http.post(this.apiUrl + "savePDFormDetails", { "records": saveData }) - // .pipe( - // catchError(this.handleError('operation', [])) - // ) - // } + return this._http.post(this.apiUrl + "savePDFormDetails", { "records": saveData }) + .pipe( + catchError(this.handleError('operation', [])) + ) + } // save pd answers // savePDQuestions(saveData: any): Observable { @@ -602,12 +603,12 @@ export class PdTrigerService { // } - // getCompaniesListsForBusiness(pdid: any): Observable { - // return this._http.post(this.apiUrl + "getCompaniesListsForBusiness", { "records":{ "pd_id" : pdid}}) - // .pipe( - // catchError(this.handleError('operation', [])) - // ) - // } + getCompaniesListsForBusiness(pdid: any): Observable { + return this._http.post(this.apiUrl + "getCompaniesListsForBusiness", { "records":{ "pd_id" : pdid}}) + .pipe( + catchError(this.handleError('operation', [])) + ) + } /** To get StateWise City List For * 1) Family Form @@ -842,5 +843,12 @@ checkExistPDDetails(datas,entity_id){ .pipe(catchError(this.handleError("checkExistPDDetails",[]))) } +getBusinessDocsToVendorForm(editId) { + const options = editId ? + { params: new HttpParams().set('pdid', editId) } : {}; + return this._http.get(this.apiUrl+'getBusinessDocsToVendorForm',options) + .pipe(catchError(this.handleError("getBusinessDocsToVendorForm",[]))) +} + }