Changes: ps

This commit is contained in:
venbatechnologies@gmail.com 2019-02-27 10:39:50 +05:30
parent ff3732cb4d
commit 15e70a8fa1
2 changed files with 636 additions and 507 deletions

View File

@ -10,17 +10,13 @@
<mat-card> <mat-card>
<mat-card-header> <mat-card-header>
<mat-card-title> <mat-card-title> PD Details </mat-card-title>
PD Details
</mat-card-title>
</mat-card-header> </mat-card-header>
<mat-card-content> <mat-card-content>
<mat-form-field style="width: 28%"> <mat-form-field style="width: 28%">
<mat-select placeholder="Lender Name" formControlName="fk_lender_id"> <mat-select placeholder="Lender Name" formControlName="fk_lender_id">
<!-- (selectionChange)="getBillingDetails(pdMain.fk_lender_id.value)" --> <!-- (selectionChange)="getBillingDetails(pdMain.fk_lender_id.value)" -->
<mat-option> <mat-option> Select </mat-option>
Select
</mat-option>
<mat-option (click)="selectedLender(LL)" *ngFor="let LL of lenderList" [value]="LL.entity_id" > <mat-option (click)="selectedLender(LL)" *ngFor="let LL of lenderList" [value]="LL.entity_id" >
{{LL.full_name}} {{LL.full_name}}
</mat-option> </mat-option>
@ -126,19 +122,20 @@
<mat-error *ngIf="pdMain.loan_amount.hasError('pattern')">Enter valid amount. </mat-error> <mat-error *ngIf="pdMain.loan_amount.hasError('pattern')">Enter valid amount. </mat-error>
</mat-form-field> </mat-form-field>
</mat-card-content>
</mat-card>
<mat-card>
<mat-card-header>
<mat-card-title>Address Details</mat-card-title>
</mat-card-header>
<mat-card-content>
<mat-form-field style="width: 96%"> <mat-form-field style="width: 96%">
<textarea matInput autocomplete="off" placeholder="Address at which PD is to be done" formControlName="addressline1" style="text-transform: uppercase"></textarea> <textarea matInput autocomplete="off" placeholder="Address at which PD is to be done" formControlName="addressline1" style="text-transform: uppercase"></textarea>
<!-- oninput="this.value = this.value.toUpperCase()" --> <!-- oninput="this.value = this.value.toUpperCase()" -->
<!-- <mat-error *ngIf="pdMain.addressline1.hasError('required')">Address1 required.</mat-error> --> <!-- <mat-error *ngIf="pdMain.addressline1.hasError('required')">Address1 required.</mat-error> -->
</mat-form-field> </mat-form-field>
<!-- <mat-form-field style="width: 28%">
<textarea matInput autocomplete="off" placeholder="Address 2" formControlName="addressline2" oninput="this.value = this.value.toUpperCase()"></textarea>
</mat-form-field>
<mat-form-field style="width: 28%">
<textarea matInput autocomplete="off" placeholder="Address 3" formControlName="addressline3" oninput="this.value = this.value.toUpperCase()"></textarea>
</mat-form-field>-->
<mat-form-field style="width: 32%"> <mat-form-field style="width: 32%">
<mat-select placeholder="State" formControlName="fk_state" (selectionChange)="getCityList(pdMain.fk_state.value)"> <mat-select placeholder="State" formControlName="fk_state" (selectionChange)="getCityList(pdMain.fk_state.value)">
<mat-option> <mat-option>
@ -155,29 +152,22 @@
</mat-form-field> </mat-form-field>
<mat-form-field style="width: 32%"> <mat-form-field style="width: 32%">
<mat-select placeholder="City" formControlName="fk_city"> <mat-select placeholder="City" formControlName="fk_city">
<mat-option> <mat-option> Select </mat-option>
Select
</mat-option>
<mat-option *ngFor="let CL of cityList" [value]="CL.city_id"> <mat-option *ngFor="let CL of cityList" [value]="CL.city_id">
{{CL.city_name}} {{CL.city_name}}
</mat-option> </mat-option>
</mat-select> </mat-select>
<!-- <mat-error *ngIf="pdMain.fk_city.hasError('required')">City Required.</mat-error> --> <!-- <mat-error *ngIf="pdMain.fk_city.hasError('required')">City Required.</mat-error> -->
</mat-form-field> </mat-form-field>
<mat-form-field style="width: 24%"> <mat-form-field style="width: 24%">
<!-- <input matInput autocomplete="off" placeholder="Pincode" formControlName="pincode" (keypress)="keyPress($event)"> -->
<!-- <mat-error *ngIf="pdMain.pincode.hasError('required')">Pincode Required.</mat-error> -->
<!-- <mat-error *ngIf="pdMain.pincode.hasError('maxlength') || pdMain.pincode.hasError('minlength')">Enter Valid Pincode. </mat-error> -->
<mat-select placeholder="Pincode" formControlName="pincode" > <mat-select placeholder="Pincode" formControlName="pincode" >
<mat-option>Select</mat-option> <mat-option>Select</mat-option>
<mat-option *ngFor="let PL of pincodeList" [value]="PL.pincode_id">{{PL.pincode}}</mat-option> <mat-option *ngFor="let PL of pincodeList" [value]="PL.pincode_id">{{PL.pincode}}</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<mat-form-field style="width: 24%" *ngIf="pdMain.pincode.value == 1" > <mat-form-field style="width: 24%" *ngIf="pdMain.pincode.value == 1" >
<input matInput autocomplete="off" placeholder="Specify Pincode" formControlName="other_pincode" (keypress)="keyPress($event)"> <input matInput autocomplete="off" placeholder="Specify Pincode" formControlName="other_pincode" (keypress)="keyPress($event)">
<mat-error *ngIf="pdMain.other_pincode.hasError('maxlength') || pdMain.other_pincode.hasError('minlength')">Enter Valid Pincode. </mat-error> <mat-error *ngIf="pdMain.other_pincode.hasError('maxlength') || pdMain.other_pincode.hasError('minlength')">Enter Valid Pincode. </mat-error>
@ -223,9 +213,69 @@
<mat-error *ngIf="pdMain.applicant_landline.hasError('maxlength') || pdMain.applicant_landline.hasError('minlength')">Enter Valid LandLine Number. </mat-error> <mat-error *ngIf="pdMain.applicant_landline.hasError('maxlength') || pdMain.applicant_landline.hasError('minlength')">Enter Valid LandLine Number. </mat-error>
</mat-form-field> </mat-form-field>
<!-- <mat-card formArrayName="items">
<mat-card-content>
<mat-list *ngFor="let coappList of items.controls; let ca = index;" [formGroupName]="ca">
<h3>Co App</h3>
<mat-list-item>
<mat-form-field style="width: 70%">
<input matInput autocomplete="off" placeholder="coapp Name" formControlName="coapplicantName" type="text">
</mat-form-field>
<div style="width:50%">
<!-- <span (click)="removeItem(d)">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above" type="button"><mat-icon>delete</mat-icon></button>
</span> --
</div>
</mat-list-item>
</mat-list>
</mat-card-content>
<mat-card-actions align="end">
</mat-card-actions>
</mat-card> -->
<!-- Phone field to be split into 2 parts. Mobile Number mandatory and optional land line number with std code. --> <!-- Phone field to be split into 2 parts. Mobile Number mandatory and optional land line number with std code. -->
</mat-card-content> </mat-card-content>
<mat-dialog-actions align="end">
<!-- <button mat-raised-button mat-icon-button matTooltip="Add Document" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" (click)="addCoApplicant()" type="button"><mat-icon>attach_file</mat-icon></button> -->
</mat-dialog-actions>
</mat-card> </mat-card>
<!---- <div fxLayout="row" fxLayoutGap="5%" fxLayoutAlign="start none">
<mat-form-field style="width: 50%">
<input matInput placeholder="Mobile" formControlName="coapplicant_mobile_no" type="text" (keypress)="keyPress($event)" required>
<!-- <mat-error *ngIf="coDetails['controls'].coapplicant_mobile_no.hasError('maxlength') || coDetails['controls'].coapplicant_mobile_no.hasError('minlength')">Enter Valid Mobile Number. </mat-error> --
</mat-form-field>
<mat-form-field style="width: 50%">
<input matInput placeholder="LandLine" formControlName="coapplicant_landline" type="text" (keypress)="keyPress($event)">
<!-- <mat-error *ngIf="coDetails['controls'].coapplicant_landline.hasError('maxlength') || coDetails['controls'].coapplicant_landline.hasError('minlength')">Enter Valid Phone Number. </mat-error> --
</mat-form-field>
</div>
<mat-form-field style="width: 100%">
<mat-select placeholder="Relationship" formControlName="relationship">
<mat-option *ngFor="let rel of relationShipList" [value]="rel.relationship_id" >
{{rel.name}}
</mat-option>
</mat-select>
</mat-form-field>
<div style="width:20%">
<span (click)="removeCoApplicant(i)">
<button mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above"><mat-icon>delete</mat-icon></button>
</span>
</div>
</div>
</mat-card>
</div>
</div>-->
<mat-card> <mat-card>
<mat-card-header> <mat-card-header>
<mat-card-title>Additional Requirements</mat-card-title> <mat-card-title>Additional Requirements</mat-card-title>
@ -306,4 +356,86 @@
<!-- <div fxLayout="row" fxLayoutWrap="wrap">
<div class="column" fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100">
<mat-card class="p-2">
<h5>Main Applicant</h5>
<mat-form-field style="width: 100%">
<input matInput placeholder="Name" formControlName="applicant_name">
<mat-error *ngIf="pdMain.applicant_name.hasError('required')">Name is Required.</mat-error>
</mat-form-field>
<div fxLayout="row" fxLayoutGap="5%" fxLayoutAlign="start none">
<mat-form-field style="width: 50%">
<input matInput placeholder="Mobile" formControlName="mobile_no" type="text" (keypress)="keyPress($event)" required>
<mat-error *ngIf="pdMain.mobile_no.hasError('maxlength') || pdMain.mobile_no.hasError('minlength')">Enter Valid Mobile Number. </mat-error>
</mat-form-field>
<mat-form-field style="width: 50%">
<input matInput placeholder="LandLine" formControlName="landline" type="text" (keypress)="keyPress($event)">
<mat-error *ngIf="pdMain.landline.hasError('maxlength') || pdMain.landline.hasError('minlength')">Enter Valid Phone Number. </mat-error>
</mat-form-field>
</div>
<mat-form-field style="width: 100%">
<input matInput placeholder="Email" formControlName="email" type="email">
<!-- <mat-error *ngIf="pdMain.email.hasError('required')">Email Required.</mat-error> ----
</mat-form-field>
</mat-card>
</div>
</div>
<div fxLayout="row" fxLayoutWrap="wrap" formArrayName="items" *ngFor="let coDetails of pdCoApplicant.controls; let i = index;">
<div class="column" fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100">
<mat-card class="p-2">
<h5>{{coDetails.controls.label.value}} {{i+1}}</h5>
<div [formGroupName]="i">
<mat-form-field style="width: 100%">
<input matInput placeholder="Name" formControlName="coapplicantName" type="text" required>
</mat-form-field>
<div fxLayout="row" fxLayoutGap="5%" fxLayoutAlign="start none">
<mat-form-field style="width: 50%">
<input matInput placeholder="Mobile" formControlName="coapplicant_mobile_no" type="text" (keypress)="keyPress($event)" required>
<mat-error *ngIf="coDetails['controls'].coapplicant_mobile_no.hasError('maxlength') || coDetails['controls'].coapplicant_mobile_no.hasError('minlength')">Enter Valid Mobile Number. </mat-error>
</mat-form-field>
<mat-form-field style="width: 50%">
<input matInput placeholder="LandLine" formControlName="coapplicant_landline" type="text" (keypress)="keyPress($event)">
<mat-error *ngIf="coDetails['controls'].coapplicant_landline.hasError('maxlength') || coDetails['controls'].coapplicant_landline.hasError('minlength')">Enter Valid Phone Number. </mat-error>
</mat-form-field>
</div>
<mat-form-field style="width: 100%">
<mat-select placeholder="Relationship" formControlName="relationship">
<mat-option *ngFor="let rel of relationShipList" [value]="rel.relationship_id" >
{{rel.name}}
</mat-option>
</mat-select>
</mat-form-field>
<div style="width:20%">
<span (click)="removeCoApplicant(i)">
<button mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above"><mat-icon>delete</mat-icon></button>
</span>
</div>
</div>
</mat-card>
</div>
</div> -->
<!-- <div fxLayout="row" fxLayoutWrap="wrap">
<div class="column" fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100">
<mat-card class="p-2">
<h5>Co-Applicant</h5>
<button mat-fab class="mr-1 mb-1" color="primary" matTooltip="Add Co-Applicant" matTooltipPosition="above" style="opacity: 0.8;border:2px;border-radius: 50%;" (click)="addCoApplicant()"><mat-icon>group_add</mat-icon><div class="mat-button-ripple mat-ripple" matripple=""></div><div class="mat-button-focus-overlay"></div></button>
<button mat-raised-button mat-button-sm color="primary" (click)="addCoApplicant()" type="button">Add More Co-Applicant</button>
</mat-card>
</div>
</div> -->

View File

@ -18,42 +18,43 @@ export class AddPdComponent implements OnInit, OnDestroy {
//@Output() loadParent = new EventEmitter<string>(); //@Output() loadParent = new EventEmitter<string>();
cancelStatus: boolean; cancelStatus: boolean;
enablePDButton: boolean; enablePDButton: boolean;
coapplicantFlag: boolean = false;
draftStatus: string; draftStatus: string;
PDTriggerStatus: string; PDTriggerStatus: string;
private notifier: NotifierService; private notifier: NotifierService;
public _PDtriggerForm: FormGroup; public _PDtriggerForm: FormGroup;
items: FormArray; items: FormArray;
addtional_requirements: FormArray; addtional_requirements: FormArray;
productList:any; productList: any;
subProductList:any; subProductList: any;
lenderList:any; lenderList: any;
lenderBranchList: any; lenderBranchList: any;
customerSegmentList:any; customerSegmentList: any;
stateList:any; stateList: any;
cityList:any; cityList: any;
pdTypeList:any; pdTypeList: any;
billingList: any; billingList: any;
relationShipList: any; relationShipList: any;
pincodeList: any = []; pincodeList: any = [];
errorMessage: any; errorMessage: any;
loanAmtInWords : any; loanAmtInWords: any;
titleList: any; titleList: any;
// Dynamic co applicant // Dynamic co applicant
createWithLongContent = false; createWithLongContent = false;
dynamicCoApplicant = []; dynamicCoApplicant = [];
disableAfterSubmit: boolean; disableAfterSubmit: boolean;
constructor(notifier: NotifierService,private _fb: FormBuilder,private route: ActivatedRoute, constructor(notifier: NotifierService, private _fb: FormBuilder, private route: ActivatedRoute,
private router: Router,private _pd: PdTrigerService, private _aws:AwsService, private ListPdComponent: ListPdComponent) { private router: Router, private _pd: PdTrigerService, private _aws: AwsService, private ListPdComponent: ListPdComponent) {
this.notifier = notifier; this.notifier = notifier;
this.disableAfterSubmit = false; this.disableAfterSubmit = false;
} }
public totalfiles: Array<File> =[]; public totalfiles: Array<File> = [];
public totalFileName = []; public totalFileName = [];
public lengthCheckToaddMore =0; public lengthCheckToaddMore = 0;
ngOnInit() { ngOnInit() {
this.draftStatus="DRAFT"; this.draftStatus = "DRAFT";
this.PDTriggerStatus="TRIGGERED"; this.PDTriggerStatus = "TRIGGERED";
this.enablePDButton=false; this.enablePDButton = false;
this.cancelStatus = false; this.cancelStatus = false;
this.ListPdComponent.showListView(false); this.ListPdComponent.showListView(false);
this.getLenderList(); this.getLenderList();
@ -68,44 +69,44 @@ export class AddPdComponent implements OnInit, OnDestroy {
} }
// load form data // load form data
loadFormData(){ loadFormData() {
this._PDtriggerForm = this._fb.group({ this._PDtriggerForm = this._fb.group({
fk_lender_id: [null], fk_lender_id: [null],
pd_branch_id: [null], pd_branch_id: [null],
lender_applicant_id: [null, Validators.compose([Validators.required])], lender_applicant_id: [null, Validators.compose([Validators.required])],
lender_contact_person: [null, Validators.compose([Validators.required])], lender_contact_person: [null, Validators.compose([Validators.required])],
lender_contact_mobile: [null, Validators.compose([Validators.minLength(10),Validators.maxLength(12),Validators.pattern('^[0-9]*$')])], lender_contact_mobile: [null, Validators.compose([Validators.minLength(10), Validators.maxLength(12), Validators.pattern('^[0-9]*$')])],
lender_stdcode:[null, Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')])], lender_stdcode: [null, Validators.compose([Validators.minLength(3), Validators.maxLength(5), Validators.pattern('^[0-9]*$')])],
lender_landline:[null, Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')])], lender_landline: [null, Validators.compose([Validators.minLength(6), Validators.maxLength(8), Validators.pattern('^[0-9]*$')])],
//lender_billing: [null], //lender_billing: [null],
fk_product_id: [null], fk_product_id: [null],
fk_subproduct_id: [null], fk_subproduct_id: [null],
fk_pd_type: [null], fk_pd_type: [null],
fk_customer_segment: [null], fk_customer_segment: [null],
loan_amount: [null,Validators.compose([Validators.pattern('^[0-9]*$')])], loan_amount: [null, Validators.compose([Validators.pattern('^[0-9]*$')])],
applicant_title_name: [''], applicant_title_name: [''],
applicant_name: [null], applicant_name: [null],
mobile_no: [null,Validators.compose([Validators.minLength(10),Validators.maxLength(10)])], mobile_no: [null, Validators.compose([Validators.minLength(10), Validators.maxLength(10)])],
// landline : [null,Validators.compose([Validators.minLength(12),Validators.maxLength(13)])], // landline : [null,Validators.compose([Validators.minLength(12),Validators.maxLength(13)])],
// email: [null], // email: [null],
applicant_stdcode:[null, Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')])], applicant_stdcode: [null, Validators.compose([Validators.minLength(3), Validators.maxLength(5), Validators.pattern('^[0-9]*$')])],
applicant_landline:[null, Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')])], applicant_landline: [null, Validators.compose([Validators.minLength(6), Validators.maxLength(8), Validators.pattern('^[0-9]*$')])],
company_name: [null], company_name: [null],
  addressline1: [null], addressline1: [null],
fk_city: [null], fk_city: [null],
fk_state: [null], fk_state: [null],
  pincode : [null],/** ,Validators.compose([Validators.minLength(6),Validators.maxLength(6)]) */ pincode: [null],/** ,Validators.compose([Validators.minLength(6),Validators.maxLength(6)]) */
other_pincode:[null,Validators.compose([Validators.minLength(6),Validators.maxLength(6)])], other_pincode: [null, Validators.compose([Validators.minLength(6), Validators.maxLength(6)])],
remarks:[null], remarks: [null],
  // allocation_type: [null], // allocation_type: [null],
  // sub_allocation_type: [null], // sub_allocation_type: [null],
//items: this._fb.array([]), items: this._fb.array([]),
documents: this._fb.array([]), documents: this._fb.array([]),
addtional_requirements: this._fb.array([this.createRequiremnt()]) addtional_requirements: this._fb.array([this.createRequiremnt()])
}); });
} }
selectedLender(lender){ selectedLender(lender) {
// console.log(JSON.stringify(lender)); // console.log(JSON.stringify(lender));
// alert(JSON.stringify(lender['branches '])); // alert(JSON.stringify(lender['branches ']));
this.lenderBranchList = lender['branches']; this.lenderBranchList = lender['branches'];
@ -113,30 +114,30 @@ export class AddPdComponent implements OnInit, OnDestroy {
} }
getLenderList(){ getLenderList() {
this._pd.getLenderDetails().subscribe( this._pd.getLenderDetails().subscribe(
data => { data => {
if (data.status == 200) { if (data.status == 200) {
this.lenderList=data.records this.lenderList = data.records
} }
}, error => this.errorMessage = <any> error); }, error => this.errorMessage = <any>error);
} }
getProductsList(){ getProductsList() {
this._pd.getProductsDetails().subscribe( this._pd.getProductsDetails().subscribe(
data => { data => {
if (data.status == 200) { if (data.status == 200) {
this.productList=data.records this.productList = data.records
} }
}, error => this.errorMessage = <any> error); }, error => this.errorMessage = <any>error);
} }
getCustomerSegmentList(){ getCustomerSegmentList() {
this._pd.getCustomersDetails().subscribe( this._pd.getCustomersDetails().subscribe(
data => { data => {
if (data.status == 200) { if (data.status == 200) {
this.customerSegmentList=data.records this.customerSegmentList = data.records
} }
}, error => this.errorMessage = <any> error); }, error => this.errorMessage = <any>error);
} }
// getStateCityList(){ // getStateCityList(){
// this._pd.getStateCityDetails().subscribe( // this._pd.getStateCityDetails().subscribe(
@ -146,7 +147,7 @@ export class AddPdComponent implements OnInit, OnDestroy {
// } // }
// }, error => this.errorMessage = <any> error); // }, error => this.errorMessage = <any> error);
// } // }
getStateCityList(){ getStateCityList() {
this._pd.getAllMasterDatas('STATE').subscribe( this._pd.getAllMasterDatas('STATE').subscribe(
data => { data => {
if (data.status == 200) { if (data.status == 200) {
@ -154,20 +155,20 @@ export class AddPdComponent implements OnInit, OnDestroy {
} }
}); });
} }
getPDTypeList(){ getPDTypeList() {
this._pd.getPDTypeDetails().subscribe( this._pd.getPDTypeDetails().subscribe(
data => { data => {
if (data.status == 200) { if (data.status == 200) {
this.pdTypeList=data.records.pd_type; this.pdTypeList = data.records.pd_type;
} }
}, error => this.errorMessage = <any> error); }, error => this.errorMessage = <any>error);
} }
//get sub product list based on prokduct id //get sub product list based on prokduct id
getSubproductList(productID:string){ getSubproductList(productID: string) {
this.subProductList= this.productList.filter(item => item.product_id == productID); this.subProductList = this.productList.filter(item => item.product_id == productID);
this.subProductList=this.subProductList[0].subproducts; this.subProductList = this.subProductList[0].subproducts;
this.subProductList = this.subProductList.filter(item => item.is_others == 0); this.subProductList = this.subProductList.filter(item => item.is_others == 0);
} }
@ -181,9 +182,9 @@ export class AddPdComponent implements OnInit, OnDestroy {
// } // }
//get city list details based on state id //get city list details based on state id
getCityList(stateID:string){ getCityList(stateID: string) {
// console.log('getCityList',stateID); // console.log('getCityList',stateID);
this._pd.getStateWiseCities(stateID).subscribe(data=>{ this._pd.getStateWiseCities(stateID).subscribe(data => {
if (data.status == 200) { if (data.status == 200) {
// console.log(data); // console.log(data);
this.cityList = data.records.cities; this.cityList = data.records.cities;
@ -193,65 +194,65 @@ export class AddPdComponent implements OnInit, OnDestroy {
} }
// get relation master details // get relation master details
getRelationMaster(){ getRelationMaster() {
let relation ="RELATIONSHIPS"; let relation = "RELATIONSHIPS";
this._pd.getAllMasterDatas(relation).subscribe( this._pd.getAllMasterDatas(relation).subscribe(
data => { data => {
if (data.status == 200) { if (data.status == 200) {
this.relationShipList=data.records; this.relationShipList = data.records;
} }
}, error => this.errorMessage = <any> error); }, error => this.errorMessage = <any>error);
} }
// get title master // get title master
getTitleMaster() { getTitleMaster() {
let relation ="TITLES"; let relation = "TITLES";
this._pd.getAllMasterDatas(relation).subscribe( this._pd.getAllMasterDatas(relation).subscribe(
data => { data => {
if (data.status == 200) { if (data.status == 200) {
this.titleList=data.records.filter(val=>val.isactive==1); this.titleList = data.records.filter(val => val.isactive == 1);
// console.log(this.titleList); // console.log(this.titleList);
// let index1 = this.titleList.map(data => data.name).indexOf("Master"); // let index1 = this.titleList.map(data => data.name).indexOf("Master");
// this.titleList.splice(index1, 1); // this.titleList.splice(index1, 1);
} }
}, error => this.errorMessage = <any> error); }, error => this.errorMessage = <any>error);
} }
createItem(): FormGroup { createItem(): FormGroup {
return this._fb.group({ return this._fb.group({
label: ['Co Applicant'],
coapplicantName: [null, Validators.compose([Validators.required])], coapplicantName: [null, Validators.compose([Validators.required])],
coapplicant_mobile_no: [null,Validators.compose([Validators.minLength(10),Validators.maxLength(10),Validators.required])], // coapplicantTitleName: [null],
coapplicant_landline : [null,Validators.compose([Validators.minLength(12),Validators.maxLength(13)])], // companyName: [null],
relationship: [null], // applicantType: 0,
// coapplicant_mobile_no: [null, Validators.compose([Validators.minLength(10), Validators.maxLength(10), Validators.required])],
// coapplicant_landline: [null, Validators.compose([Validators.minLength(12), Validators.maxLength(13)])],
// relationship: [null],
}); });
}; };
addCoApplicant() { addCoApplicant() {
if(this._PDtriggerForm.valid){
this.items = this._PDtriggerForm.get('items') as FormArray; this.items = this._PDtriggerForm.get('items') as FormArray;
this.items.push(this.createItem()); this.items.push(this.createItem());
} }
}
addMoreDocs() { addMoreDocs() {
if(this.totalfiles.length!=0){ if (this.totalfiles.length != 0) {
if (this.documents.value[0].doc_name != "" && ((this.lengthCheckToaddMore) === (this.totalfiles.length))) {
if( this.documents.value[0].doc_name != "" && ((this.lengthCheckToaddMore) === (this.totalfiles.length)) )
{
this.documents.insert(0, this.generateDocuments()) this.documents.insert(0, this.generateDocuments())
this.lengthCheckToaddMore=this.lengthCheckToaddMore+1; this.lengthCheckToaddMore = this.lengthCheckToaddMore + 1;
} }
} }
else if(this.totalfiles.length===0 && this.lengthCheckToaddMore===0){ else if (this.totalfiles.length === 0 && this.lengthCheckToaddMore === 0) {
this.documents.insert(0, this.generateDocuments()) this.documents.insert(0, this.generateDocuments())
this.lengthCheckToaddMore=this.lengthCheckToaddMore+1; this.lengthCheckToaddMore = this.lengthCheckToaddMore + 1;
} }
} }
generateDocuments(): FormGroup { generateDocuments(): FormGroup {
return this._fb.group({ return this._fb.group({
doc_name: [null],//Validators.compose([Validators.required]) doc_name: [null],//Validators.compose([Validators.required])
documentFile : [null],//, Validators.compose([Validators.required]) documentFile: [null],//, Validators.compose([Validators.required])
}); });
} }
@ -259,7 +260,8 @@ export class AddPdComponent implements OnInit, OnDestroy {
return this._PDtriggerForm.get('documents') as FormArray; return this._PDtriggerForm.get('documents') as FormArray;
}; };
get pdMain() { get pdMain() {
return this._PDtriggerForm.controls; } return this._PDtriggerForm.controls;
}
// get pdCoApplicant() { return this._PDtriggerForm.get('items') as FormArray; } // get pdCoApplicant() { return this._PDtriggerForm.get('items') as FormArray; }
removeCoApplicant(i: number) { removeCoApplicant(i: number) {
@ -267,16 +269,16 @@ export class AddPdComponent implements OnInit, OnDestroy {
control.removeAt(i); control.removeAt(i);
} }
removeItem(index: number) { removeItem(index: number) {
this.totalfiles.splice(index,1); this.totalfiles.splice(index, 1);
this.totalFileName.splice(index,1); this.totalFileName.splice(index, 1);
this.documents.removeAt(index); this.documents.removeAt(index);
this.lengthCheckToaddMore=this.lengthCheckToaddMore-1; this.lengthCheckToaddMore = this.lengthCheckToaddMore - 1;
} }
get pdRequirements() { return this._PDtriggerForm.get('addtional_requirements') as FormArray; } get pdRequirements() { return this._PDtriggerForm.get('addtional_requirements') as FormArray; }
createRequiremnt(): FormGroup { createRequiremnt(): FormGroup {
return this._fb.group({ return this._fb.group({
add_req_id:[null], add_req_id: [null],
add_requirement: [null], add_requirement: [null],
isactive: [1], isactive: [1],
}); });
@ -291,7 +293,7 @@ export class AddPdComponent implements OnInit, OnDestroy {
requirement_control.removeAt(index); requirement_control.removeAt(index);
} }
public fileSelectionEvent(fileInput: any,oldIndex:number) { public fileSelectionEvent(fileInput: any, oldIndex: number) {
if (fileInput.target.files && fileInput.target.files[0]) { if (fileInput.target.files && fileInput.target.files[0]) {
@ -299,33 +301,30 @@ export class AddPdComponent implements OnInit, OnDestroy {
reader.onload = (event: any) => { reader.onload = (event: any) => {
} }
if(oldIndex==0) if (oldIndex == 0) {
{
this.totalfiles.unshift((fileInput.target.files[0])) this.totalfiles.unshift((fileInput.target.files[0]))
this.totalFileName.unshift(fileInput.target.files[0].name) this.totalFileName.unshift(fileInput.target.files[0].name)
} }
else else {
{ this.totalfiles[oldIndex] = (fileInput.target.files[0]);
this.totalfiles[oldIndex]=(fileInput.target.files[0]); this.totalFileName[oldIndex] = fileInput.target.files[0].name
this.totalFileName[oldIndex]=fileInput.target.files[0].name
} }
reader.readAsDataURL(fileInput.target.files[0]); reader.readAsDataURL(fileInput.target.files[0]);
} }
if(this.totalfiles.length == 1) if (this.totalfiles.length == 1) {
{ this.lengthCheckToaddMore = 1;
this.lengthCheckToaddMore=1;
} }
} }
// save pd in draft // save pd in draft
saveDraftPD(formValue: any, status:string){ saveDraftPD(formValue: any, status: string) {
//alert('Inside The Draft PD'); //alert('Inside The Draft PD');
this.submitPdDetails(formValue, status); this.submitPdDetails(formValue, status);
} }
//trigger pd //trigger pd
triggerPD(formValue: any, status:string){ triggerPD(formValue: any, status: string) {
this._PDtriggerForm.controls['fk_lender_id'].setValidators([Validators.required]); this._PDtriggerForm.controls['fk_lender_id'].setValidators([Validators.required]);
this._PDtriggerForm.controls['fk_lender_id'].updateValueAndValidity(); this._PDtriggerForm.controls['fk_lender_id'].updateValueAndValidity();
@ -370,7 +369,7 @@ export class AddPdComponent implements OnInit, OnDestroy {
} }
// this is for clear custom validator required fields // this is for clear custom validator required fields
clearCustomValidatorFields(){ clearCustomValidatorFields() {
this._PDtriggerForm.controls['fk_lender_id'].clearValidators(); this._PDtriggerForm.controls['fk_lender_id'].clearValidators();
this._PDtriggerForm.controls['fk_lender_id'].updateValueAndValidity(); this._PDtriggerForm.controls['fk_lender_id'].updateValueAndValidity();
@ -414,115 +413,114 @@ export class AddPdComponent implements OnInit, OnDestroy {
} }
// common function for both draft and process pd // common function for both draft and process pd
submitPdDetails(formValue: any, status:string) { submitPdDetails(formValue: any, status: string) {
if(this._PDtriggerForm.invalid) { if (this._PDtriggerForm.invalid) {
this.validateAllFormFields(this._PDtriggerForm); this.validateAllFormFields(this._PDtriggerForm);
this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!');
return; return;
} }
else { else {
if((formValue.lender_contact_mobile == '' || formValue.lender_contact_mobile == null) && (formValue.lender_stdcode == '' || formValue.lender_stdcode == null && formValue.lender_landline == '' || formValue.lender_landline == null )){ if ((formValue.lender_contact_mobile == '' || formValue.lender_contact_mobile == null) && (formValue.lender_stdcode == '' || formValue.lender_stdcode == null && formValue.lender_landline == '' || formValue.lender_landline == null)) {
this.notifier.notify('warning', 'Either Mobile or Landline Need.!'); this.notifier.notify('warning', 'Either Mobile or Landline Need.!');
return; return;
} }
else{ else {
this.disableAfterSubmit=true; this.disableAfterSubmit = true;
let concat_landline let concat_landline
let concat_landline1 let concat_landline1
if(formValue.lender_stdcode != null || formValue.lender_landline != null){ if (formValue.lender_stdcode != null || formValue.lender_landline != null) {
if(formValue.lender_stdcode != '' && formValue.lender_landline != ''){ if (formValue.lender_stdcode != '' && formValue.lender_landline != '') {
concat_landline = formValue.lender_stdcode +'-'+formValue.lender_landline; concat_landline = formValue.lender_stdcode + '-' + formValue.lender_landline;
} }
else { else {
concat_landline = null; concat_landline = null;
} }
} }
else{ else {
concat_landline = null; concat_landline = null;
} }
if(formValue.applicant_stdcode != null || formValue.applicant_landline != null){ if (formValue.applicant_stdcode != null || formValue.applicant_landline != null) {
if(formValue.applicant_stdcode != '' && formValue.applicant_landline != ''){ if (formValue.applicant_stdcode != '' && formValue.applicant_landline != '') {
concat_landline1 = formValue.applicant_stdcode +'-'+formValue.applicant_landline; concat_landline1 = formValue.applicant_stdcode + '-' + formValue.applicant_landline;
} }
else{ else {
concat_landline1 = null; concat_landline1 = null;
} }
} }
else{ else {
concat_landline1 = null; concat_landline1 = null;
} }
let pd_details:any={ let pd_details: any = {
"fk_lender_id":formValue.fk_lender_id, "fk_lender_id": formValue.fk_lender_id,
"lender_applicant_id":formValue.lender_applicant_id, "lender_applicant_id": formValue.lender_applicant_id,
"pd_branch_id":formValue.pd_branch_id, "pd_branch_id": formValue.pd_branch_id,
"pd_contact_person":formValue.lender_contact_person, "pd_contact_person": formValue.lender_contact_person,
"pd_contact_mobileno":formValue.lender_contact_mobile, "pd_contact_mobileno": formValue.lender_contact_mobile,
"pd_contact_landline":concat_landline, "pd_contact_landline": concat_landline,
"fk_product_id":formValue.fk_product_id, "fk_product_id": formValue.fk_product_id,
"fk_subproduct_id":formValue.fk_subproduct_id, "fk_subproduct_id": formValue.fk_subproduct_id,
"fk_pd_type":formValue.fk_pd_type, "fk_pd_type": formValue.fk_pd_type,
"fk_customer_segment":formValue.fk_customer_segment, "fk_customer_segment": formValue.fk_customer_segment,
"loan_amount":formValue.loan_amount, "loan_amount": formValue.loan_amount,
"addressline1":formValue.addressline1.toUpperCase(), "addressline1": formValue.addressline1.toUpperCase(),
"fk_city":formValue.fk_city, "fk_city": formValue.fk_city,
"fk_state":formValue.fk_state, "fk_state": formValue.fk_state,
"pincode":formValue.pincode, "pincode": formValue.pincode,
"other_pincode":formValue.other_pincode , "other_pincode": formValue.other_pincode,
"remarks":formValue.remarks, "remarks": formValue.remarks,
"pd_status": status, "pd_status": status,
"fk_createdby" : this._aws.getlocale(), "fk_createdby": this._aws.getlocale(),
}; };
var pd_applicant_details: any=[]; var pd_applicant_details: any = [];
if(formValue.applicant_name){ if (formValue.applicant_name) {
pd_applicant_details.push({ pd_applicant_details.push({
"applicant_name":formValue.applicant_name, "applicant_name": formValue.applicant_name,
"applicant_title_name":formValue.applicant_title_name, "applicant_title_name": formValue.applicant_title_name,
"company_name":formValue.company_name, "company_name": formValue.company_name,
"mobile_no":formValue.mobile_no, "mobile_no": formValue.mobile_no,
"landline":concat_landline1 , "landline": concat_landline1,
"applicant_type":1, "applicant_type": 1,
"relation":"", "relation": "",
}); });
} }
formValue.items.forEach((itemElement, itemIndex) => {
// formValue.items.forEach((itemElement, itemIndex) => { let obj1 = {
// let obj1 = { "applicant_name": itemElement.coapplicantName,
// "applicant_name":itemElement.coapplicantName, "applicant_title_name": itemElement.applicant_title_name,
// "relation":itemElement.relationship, "company_name": itemElement.company_name,
// "email":"", "mobile_no": itemElement.coapplicant_mobile_no,
// "mobile_no":itemElement.coapplicant_mobile_no, "landline": itemElement.coapplicant_landline,
// "landline":itemElement.coapplicant_landline, "applicant_type": 0,
// "applicant_type":0, "relation": "",
// } }
// pd_applicant_details.push(obj1) pd_applicant_details.push(obj1)
// }); });
// docs details // docs details
let pd_form: FormData = new FormData(); let pd_form: FormData = new FormData();
for(let j=0;j<this.totalfiles.length; j++) for (let j = 0; j < this.totalfiles.length; j++) {
{ pd_form.append('pddocuments[]', <File>this.totalfiles[j])
pd_form.append('pddocuments[]',<File>this.totalfiles[j])
} }
//reverseFileNames=this.totalFileName.reverse(); //reverseFileNames=this.totalFileName.reverse();
let AllFilesObj= [] let AllFilesObj = []
formValue.documents.forEach((element, index) => { formValue.documents.forEach((element, index) => {
AllFilesObj.push(element.doc_name); AllFilesObj.push(element.doc_name);
}); });
pd_form.append("pd_details",JSON.stringify(pd_details)) pd_form.append("pd_details", JSON.stringify(pd_details))
if(pd_applicant_details.length>0){ if (pd_applicant_details.length > 0) {
pd_form.append("pd_applicant_details",JSON.stringify(pd_applicant_details)) pd_form.append("pd_applicant_details", JSON.stringify(pd_applicant_details))
} }
pd_form.append("pd_document_titles",JSON.stringify(AllFilesObj)) pd_form.append("pd_document_titles", JSON.stringify(AllFilesObj))
if(formValue.addtional_requirements.length > 0){ if (formValue.addtional_requirements.length > 0) {
pd_form.append("addtional_requirements",JSON.stringify(formValue.addtional_requirements)) pd_form.append("addtional_requirements", JSON.stringify(formValue.addtional_requirements))
} }
// console.log('pd_form',pd_form); // console.log('pd_form',pd_form);
@ -544,16 +542,16 @@ export class AddPdComponent implements OnInit, OnDestroy {
} }
} }
} }
loadPdListCompoent(from:boolean) { loadPdListCompoent(from: boolean) {
//alert(from); //alert(from);
if(from){ if (from) {
// alert('if'+from); // alert('if'+from);
this.router.navigate([ '../../' ], { relativeTo: this.route }); this.router.navigate(['../../'], { relativeTo: this.route });
this.ListPdComponent.pdListLoad(true); this.ListPdComponent.pdListLoad(true);
} }
else{ else {
// alert(from); // alert(from);
this.router.navigate([ '../../' ], { relativeTo: this.route }); this.router.navigate(['../../'], { relativeTo: this.route });
this.ListPdComponent.showListView(true); this.ListPdComponent.showListView(true);
} }
@ -577,7 +575,7 @@ export class AddPdComponent implements OnInit, OnDestroy {
} }
} }
// validate all form group and form array fields // validate all form group and form array fields
validateAllFormFields(formGroup: any) { validateAllFormFields(formGroup: any) {
Object.keys(formGroup.controls).forEach(field => { Object.keys(formGroup.controls).forEach(field => {
const control = formGroup.get(field); const control = formGroup.get(field);
@ -589,18 +587,17 @@ validateAllFormFields(formGroup: any) {
this.validateAllFormFields(control); this.validateAllFormFields(control);
} }
}); });
} }
/** To Convert Amount into Words */ /** To Convert Amount into Words */
inWords(e,flag:number){ inWords(e, flag: number) {
switch(flag){ switch (flag) {
case 1 : case 1:
this.loanAmtInWords = this._pd.convertNumberToWords(e.target.value); this.loanAmtInWords = this._pd.convertNumberToWords(e.target.value);
break; break;
default: default:
break; break;
} }
} }
} }