address related hanges : ps

This commit is contained in:
venbatechnologies@gmail.com 2019-06-21 18:34:06 +05:30
parent dc50a75373
commit c210529695
4 changed files with 493 additions and 302 deletions

View File

@ -65,7 +65,7 @@
</mat-form-field>
<mat-form-field style="width: 24%">
<mat-select placeholder="Pincode" formControlName="pincode">
<mat-select placeholder="Pincode" formControlName="pincode" (selectionChange)="setOthers($event.value,i,1)">
<mat-option>Select</mat-option>
<mat-option *ngFor="let PL of pincodeData"
[value]="PL.pincode_id">{{PL.pincode}}</mat-option>
@ -77,9 +77,9 @@
<input matInput autocomplete="off"
placeholder="Specify Pincode *"
formControlName="pincode_others" OnlyNumber type="text">
<!-- <mat-error
<mat-error
*ngIf="init_addr.controls['pincode_others'].hasError('required')">
Pincode Required</mat-error> -->
Pincode Required</mat-error>
</mat-form-field>
</div>
@ -146,7 +146,7 @@
<mat-form-field style="width: 24%">
<mat-select placeholder="Pincode"
formControlName="alternative_pincode">
formControlName="alternative_pincode" (selectionChange)="setOthers($event.value,a,2)">
<mat-option>Select</mat-option>
<mat-option
*ngFor="let PL of alertnativePincodeData"
@ -158,12 +158,12 @@
<mat-form-field style="width: 24%"
*ngIf="alter_addr.get('alternative_pincode').value == 1">
<input matInput autocomplete="off"
placeholder="Specify Pincode"
placeholder="Specify Pincode "
formControlName="alternative_pincode_others"
OnlyNumber type="text">
<!-- <mat-error
OnlyNumber type="text" required>
<mat-error
*ngIf="alter_addr.controls['alternative_pincode_others'].hasError('required')">
Pincode Required</mat-error> -->
Pincode Required</mat-error>
</mat-form-field>
</div>
@ -298,15 +298,30 @@
<mat-form-field style="width: 24%;"
*ngIf="addressForm.controls['uom'].value == 1 ">
<input matInput placeholder="Specify UOM *" formControlName="uom_others"
autocomplete="off">
<input matInput placeholder="Specify UOM" formControlName="uom_others"
autocomplete="off" required>
<mat-error
*ngIf="addressForm.controls['uom_others'].hasError('required')">
UOM Required</mat-error>
</mat-form-field>
</div>
</div>
<!-- <div fxLayout="row wrap">
<div fxFlex="100">
<mat-form-field style="width: 96%">
<mat-select placeholder="Was the Company name board sighted ?" formControlName="was_the_company_name_board_sighted"
required>
<mat-option value="yes">Yes</mat-option>
<mat-option value="no">No</mat-option>
!-- <mat-option value="not applicable">Not Applicable</mat-option> --
</mat-select>
<mat-error *ngIf="addressForm.controls['was_the_company_name_board_sighted'].hasError('required')">Was the Company name board sighted ? Required</mat-error>
</mat-form-field>
</div>
</div> -->

View File

@ -130,15 +130,16 @@ export class AddressComponent implements OnInit {
'state': datas.fk_state,
'city': datas.fk_city,
'pincode': datas.pincode_id,
'pincode_others': datas.pincode_id == 1 ? datas.other_pincode :'',
// 'pincode_others': datas.pincode_id == 1 ? datas.other_pincode :'',
}
this.getCityAndPincodeDetails(datas.fk_state, index, 1);
control.push(this.createAddresses(obj));
// if(datas.pincode == 1) {
// let ChildCtrl: any = control.controls[index];
// ChildCtrl.controls['pincode_others'].setValue(datas.pincode_others);
// ChildCtrl.controls['pincode_others'].updateValueAndValidity();
// }
this.setOthers(+datas.pincode_id, index, 1);
if(datas.pincode == 1) {
let ChildCtrl: any = control.controls[index];
ChildCtrl.controls['pincode_others'].setValue(datas.other_pincode);
ChildCtrl.controls['pincode_others'].updateValueAndValidity();
}
this.addressForm.controls.pd_location.setValue(datas.pd_location ? datas.pd_location : '');
@ -179,6 +180,7 @@ export class AddressComponent implements OnInit {
}
let initiated_address_check =data.records.hasOwnProperty('is_pd_done_on_initiated_address') ? data.records.is_pd_done_on_initiated_address : true ;
this.addressForm.controls.is_pd_done_on_initiated_address.setValue(initiated_address_check);
// this.addressForm.controls.was_the_company_name_board_sighted.setValue('');
this.addressForm.controls.address_form_remark.setValue('');
// else{
// control.push(this.createAddresses(null));
@ -203,6 +205,7 @@ export class AddressComponent implements OnInit {
comment_locality: ['', Validators.compose([Validators.required])],
estimated_area: [''],
uom: [''],
// was_the_company_name_board_sighted:['', Validators.compose([Validators.required])],
address_form_remark: ['']
});
}
@ -236,7 +239,6 @@ export class AddressComponent implements OnInit {
/** FOR Form Field For Alternative Address Array */
createAlternativeAddresses(AddressDetails): FormGroup {
if (AddressDetails != null) {
console.log('not null');
return this.fb.group({
alternative_address: [this.transformName(AddressDetails.alternative_address), Validators.compose([Validators.required])],
alternative_state: [AddressDetails.alternative_state],
@ -333,6 +335,7 @@ export class AddressComponent implements OnInit {
// Add and Remove The SpecifyOthers Field
setOthers(e, i, flag) {
console.log(e,i,flag);
switch (flag) {
case 1:
const control = <FormArray>this.addressForm.controls['addresses'];
@ -484,9 +487,6 @@ export class AddressComponent implements OnInit {
records.is_pd_done_on_initiated_address = this.addressForm.controls.is_pd_done_on_initiated_address.value
if (this.addressForm.controls.is_pd_done_on_initiated_address.value == true) {
if(records.addresses[0].pincode != 1){
delete records.addresses[0].pincode_others
}
records.addresses[0].address_type = this.addressForm.controls.address_type.value;
if (this.addressForm.controls.address_type.value == 1) {
records.addresses[0].address_type_others = this.addressForm.controls.address_type_others.value;
@ -510,9 +510,6 @@ export class AddressComponent implements OnInit {
else if (this.addressForm.controls.is_pd_done_on_initiated_address.value == false) {
records.alternative_addresses = this.addressForm.controls.alternative_addresses.value;
records.alternative_addresses[0].address_type = this.addressForm.controls.address_type.value;
if(records.addresses[0].alternative_pincode != 1){
delete records.addresses[0].alternative_pincode_others
}
if (this.addressForm.controls.address_type.value == 1) {
records.alternative_addresses[0].address_type_others = this.addressForm.controls.address_type_others.value;
}
@ -532,6 +529,7 @@ export class AddressComponent implements OnInit {
records.alternative_addresses[0].uom_others = this.addressForm.controls.uom_others.value;
}
}
// records.was_the_company_name_board_sighted = this.addressForm.controls.was_the_company_name_board_sighted.value;
records.address_form_remark = this.addressForm.controls.address_form_remark.value;
records.pdid = this.pdid;
records.parent_pdid = this.parent_pdid;
@ -630,10 +628,16 @@ export class AddressComponent implements OnInit {
'state': datas.state,
'city': datas.city,
'pincode': datas.pincode,
'pincode_others': datas.pincode ? datas.pincode_others : ''
// 'pincode_others': datas.pincode ? datas.pincode_others : ''
}
this.getCityAndPincodeDetails(datas.state, index, 1);
control.push(this.createAddresses(obj));
this.setOthers(+datas.pincode, index, 1);
if(datas.pincode == 1) {
let Ctrl: any = control.controls[index];
Ctrl.controls['pincode_others'].setValue(datas.pincode_others);
Ctrl.controls['pincode_others'].updateValueAndValidity();
}
if (datas.address_type_others == "" || datas.address_type_others == null){
delete datas.address_type_others;
@ -686,7 +690,7 @@ export class AddressComponent implements OnInit {
this.addressForm.controls.uom.setValue(datas.uom);
this.setOthers(datas.uom, '', 5);
if (data.records.uom == 1) {
if (datas.uom == 1) {
this.addressForm.controls.uom_others.setValue(datas.uom_others);
}
}
@ -716,12 +720,18 @@ export class AddressComponent implements OnInit {
'alternative_state': datas.alternative_state,
'alternative_city': datas.alternative_city,
'alternative_pincode': datas.alternative_pincode,
'alternative_pincode_others': datas.alternative_pincode == 1 ? datas.alternative_pincode_others : '',
// 'alternative_pincode_others': datas.alternative_pincode == 1 ? datas.alternative_pincode_others : '',
'reason_for_alternative_address': datas.reason_for_alternative_address,
}
this.getCityAndPincodeDetails(datas.alternative_state, index, 2);
alternative_address_control.push(this.createAlternativeAddresses(obj));
this.setOthers(+datas.alternative_pincode, index, 2);
if(datas.alternative_pincode == 1) {
let AltCtrl: any = alternative_address_control.controls[index];
AltCtrl.controls['alternative_pincode_others'].setValue(datas.alternative_pincode_others);
AltCtrl.controls['alternative_pincode_others'].updateValueAndValidity();
}
this.addressForm.controls.pd_location.setValue(datas.pd_location);
this.addressForm.controls.address_type.setValue(datas.address_type);
@ -747,13 +757,14 @@ export class AddressComponent implements OnInit {
this.addressForm.controls.estimated_area.setValue(datas.estimated_area);
this.addressForm.controls.uom.setValue(datas.uom);
this.setOthers(datas.uom, '', 5);
if (data.records.uom == 1) {
if (datas.uom == 1) {
this.addressForm.controls.uom_others.setValue(datas.uom_others);
}
});
}
}
// this.addressForm.controls.was_the_company_name_board_sighted.setValue(data.records.hasOwnProperty('was_the_company_name_board_sighted') ? data.records.was_the_company_name_board_sighted : '');
this.addressForm.controls.address_form_remark.setValue(data.records.address_form_remark);
}
else {

View File

@ -19,7 +19,8 @@
<div fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<div fxFlex="100">
<div formArrayName="business_assets_for_address" fxFill>
<div *ngFor="let itemrow of _businessAssetsQuesFrom.controls.business_assets_for_address['controls']; let i=index; let last=last;">
<div
*ngFor="let itemrow of _businessAssetsQuesFrom.controls.business_assets_for_address['controls']; let i=index; let last=last;">
<div [formGroupName]="i">
<mat-card>
<mat-card-header>
@ -28,35 +29,40 @@
</mat-card-title>
</mat-card-header>
<div fxLayout="row wrap" fxLayoutGap="5px" fxLayoutAlign="start none">
<mat-form-field style="width: 95%;">
<mat-select placeholder="Is this the business address ? " (selectionChange)="setRequiredValidation($event.value,itemrow,1);"
<mat-select placeholder="Is this the business address ? "
(selectionChange)="setRequiredValidation($event.value,itemrow,1);"
formControlName="business_address_availability" required>
<mat-option>Select</mat-option>
<mat-option value="yes">Yes</mat-option>
<mat-option value="no">No</mat-option>
</mat-select>
<mat-error *ngIf="itemrow.controls['business_address_availability'].hasError('required')">Business address Required</mat-error>
<mat-error *ngIf="itemrow.controls['business_address_availability'].hasError('required')">
Business address Required</mat-error>
</mat-form-field>
</div>
<div fxLayout="row wrap" fxLayoutGap="5px" fxLayoutAlign="start none" *ngIf=" itemrow.get('business_address_availability').value == 'yes'">
<div fxLayout="row wrap" fxLayoutGap="5px" fxLayoutAlign="start none"
*ngIf=" itemrow.get('business_address_availability').value == 'yes'">
<div style="width:95%">
<label style="padding-left:2%">How long has business been operated from this premise?</label>
<mat-form-field>
<mat-label>Year</mat-label>
<input matInput placeholder="No of years (Eg. 10)" autocomplete="off" formControlName="business_years"
<mat-label>Year</mat-label>
<input matInput placeholder="No of years (Eg. 10)" autocomplete="off"
formControlName="business_years"
(change)="checkWithExistBusinessYear($event.target.value,i)" OnlyNumber type="text">
<mat-hint style="color: red;">{{yearErrorMessage[i]}}</mat-hint>
<mat-error *ngIf="itemrow.controls['business_years'].hasError('required')">Year Required</mat-error>
<mat-error *ngIf="itemrow.controls['business_years'].hasError('required')">Year Required
</mat-error>
<!-- <mat-error *ngIf="!_businessAssetsQuesFrom.controls['business_years'].value.valid">Year's
Required</mat-error> -->
</mat-form-field>
<mat-form-field>
<mat-label>Month</mat-label>
<input matInput placeholder="No of months (Eg. 6)" autocomplete="off" formControlName="business_month"
OnlyNumber type="text" (change)="ConvertMonthintoYear($event.target.value,i)">
<mat-label>Month</mat-label>
<input matInput placeholder="No of months (Eg. 6)" autocomplete="off"
formControlName="business_month" OnlyNumber type="text"
(change)="ConvertMonthintoYear($event.target.value,i)">
<mat-hint style="color: red;">{{monthErrorMessage[i]}}</mat-hint>
<!-- <mat-error *ngIf="!_businessAssetsQuesFrom.controls['business_month'].value.valid">Month's
Required</mat-error> -->
@ -65,20 +71,23 @@
<mat-form-field style="width: 95%;">
<mat-select [placeholder]="placeholderName[i] ? placeholderName[i] :'Was any business activity seen at the Address Type during PD visit?'"
<mat-select
[placeholder]="placeholderName[i] ? placeholderName[i] :'Was any business activity seen at the Address Type during PD visit?'"
formControlName="business_is_pd_visited">
<mat-option value="yes">Yes</mat-option>
<mat-option value="no">No</mat-option>
</mat-select>
<mat-error *ngIf="itemrow.controls['business_is_pd_visited'].hasError('required')">Business Activity
Required</mat-error>
<mat-error *ngIf="itemrow.controls['business_is_pd_visited'].hasError('required')">Business
Activity
Required</mat-error>
</mat-form-field>
<mat-form-field *ngIf=" itemrow.get('business_is_pd_visited').value != ''" style="width: 95%;">
<input matInput autocomplete="off" placeholder="Remarks" formControlName="business_pd_visited_remark">
<input matInput autocomplete="off" placeholder="Remarks"
formControlName="business_pd_visited_remark">
<mat-error *ngIf="itemrow.controls['business_pd_visited_remark'].hasError('required')">Remarks
Required</mat-error>
Required</mat-error>
</mat-form-field>
</div>
@ -92,54 +101,73 @@
<mat-option value="owned">Owned</mat-option>
<mat-option value="rented">Rented</mat-option>
</mat-select>
<mat-error *ngIf="itemrow.controls['business_ownership_type'].hasError('required')">Ownership Type Required</mat-error>
<mat-error *ngIf="itemrow.controls['business_ownership_type'].hasError('required')">Ownership
Type Required</mat-error>
</mat-form-field>
<mat-form-field style="width:45%" *ngIf="(itemrow.get('business_ownership_type').value == 'rented')">
<input matInput autocomplete="off" [placeholder]= "'Monthly ' + address_type + ' Rent Amount'" formControlName="business_monthly_rented_amt" OnlyNumber type="text">
<mat-hint align="start" style="font-size:90%" *ngIf="itemrow.get('business_monthly_rented_amt').value != ''">{{"&#8377;"}} {{itemrow.get('business_monthly_rented_amt').value | numberToWords}} Only</mat-hint>
<mat-error>Monthly Rent Amount Required</mat-error>
<mat-form-field style="width:45%"
*ngIf="(itemrow.get('business_ownership_type').value == 'rented')">
<input matInput autocomplete="off" [placeholder]="'Monthly ' + address_type + ' Rent Amount'"
formControlName="business_monthly_rented_amt" OnlyNumber type="text">
<mat-hint align="start" style="font-size:90%"
*ngIf="itemrow.get('business_monthly_rented_amt').value != ''">{{"&#8377;"}}
{{itemrow.get('business_monthly_rented_amt').value | numberToWords}} Only</mat-hint>
<mat-error>Monthly Rent Amount Required</mat-error>
</mat-form-field>
<div fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none" *ngIf="(itemrow.get('business_ownership_type').value == 'owned')">
<div fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none"
*ngIf="(itemrow.get('business_ownership_type').value == 'owned')">
<mat-form-field style="width:45%">
<input matInput placeholder="Approximate Market Value" formControlName="business_approximate_market_value"
OnlyNumber type="text" autocomplete="off">
<mat-hint align="start" style="font-size:90%" *ngIf="itemrow.get('business_approximate_market_value').value != ''">{{"&#8377;"}} {{itemrow.get('business_approximate_market_value').value | numberToWords}} Only</mat-hint>
<mat-error *ngIf="itemrow.controls['business_approximate_market_value'].hasError('required')">Approximate Market Value Required</mat-error>
<input matInput placeholder="Approximate Market Value"
formControlName="business_approximate_market_value" OnlyNumber type="text"
autocomplete="off">
<mat-hint align="start" style="font-size:90%"
*ngIf="itemrow.get('business_approximate_market_value').value != ''">{{"&#8377;"}}
{{itemrow.get('business_approximate_market_value').value | numberToWords}} Only</mat-hint>
<mat-error
*ngIf="itemrow.controls['business_approximate_market_value'].hasError('required')">
Approximate Market Value Required</mat-error>
</mat-form-field>
<mat-form-field style="width:45%">
<mat-select multiple [placeholder]="address_type + ' Owned by'" formControlName="business_name_of_the_owner"
[compareWith]="compareObjects" (selectionChange)="setOtherOwnerOfAddress($event.value,i)">
<mat-select multiple [placeholder]="address_type + ' Owned by'"
formControlName="business_name_of_the_owner" [compareWith]="compareObjects"
(selectionChange)="setOtherOwnerOfAddress($event.value,i)">
<mat-optgroup *ngFor="let group of mergeCompanyApplicant" [label]="group.groupName">
<mat-option *ngFor="let val of group.groupValues" [value]="val">
{{val.group_id != 2 ? val.name : val.name | titlecase}}
</mat-option>
</mat-optgroup>
</mat-select>
<mat-error *ngIf="itemrow.controls['business_name_of_the_owner'].hasError('required')">Asset Owned by Required</mat-error>
<mat-error *ngIf="itemrow.controls['business_name_of_the_owner'].hasError('required')">Asset
Owned by Required</mat-error>
</mat-form-field>
<mat-form-field style="width:45%" *ngIf="isOtherOwnerForAddress[i]">
<input matInput placeholder="Specify Asset Owned Name" formControlName="business_name_of_the_other_owner" [value]="itemrow.get('business_name_of_the_other_owner').value | titlecase"
autocomplete="off" >
<mat-error *ngIf="itemrow.controls['business_name_of_the_other_owner'].hasError('required')">Asset Owned by Required</mat-error>
<input matInput placeholder="Specify Asset Owned Name"
formControlName="business_name_of_the_other_owner"
[value]="itemrow.get('business_name_of_the_other_owner').value | titlecase"
autocomplete="off">
<mat-error
*ngIf="itemrow.controls['business_name_of_the_other_owner'].hasError('required')">Asset
Owned by Required</mat-error>
</mat-form-field>
<mat-form-field style="width:45%">
<mat-label>Age of Asset in Years</mat-label>
<input matInput autocomplete="off" placeholder="eg.99" formControlName="business_vintage"
minlength="1" maxlength="2" OnlyNumber type="text" (keyup)="calculateVintagePurchase($event.target.value,i,3)">
minlength="1" maxlength="2" OnlyNumber type="text"
(keyup)="calculateVintagePurchase($event.target.value,i,3)">
<!-- <mat-error> Invalid format</mat-error> -->
</mat-form-field>
<mat-form-field style="width:45%">
<mat-label>Purchase Year</mat-label>
<input matInput autocomplete="off" placeholder="YYYY eg.2018" formControlName="business_purchase_year"
minlength="4" maxlength="4" OnlyNumber type="text" (keyup)="calculateVintagePurchase($event.target.value,i,4)">
<input matInput autocomplete="off" placeholder="YYYY eg.2018"
formControlName="business_purchase_year" minlength="4" maxlength="4" OnlyNumber
type="text" (keyup)="calculateVintagePurchase($event.target.value,i,4)">
<!-- <mat-error> Invalid year format</mat-error> -->
</mat-form-field>
</div>
@ -147,8 +175,10 @@
<span>
<div fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field style="width:95%" *ngIf="(itemrow.get('business_ownership_type').value == 'owned')">
<mat-select placeholder="Is There a Loan Existing Against This Asset?" formControlName="business_emi">
<mat-form-field style="width:95%"
*ngIf="(itemrow.get('business_ownership_type').value == 'owned')">
<mat-select placeholder="Is There a Loan Existing Against This Asset?"
formControlName="business_emi">
<mat-option>Select</mat-option>
<mat-option value="yes">Yes</mat-option>
<mat-option value="no">No</mat-option>
@ -174,16 +204,19 @@
<mat-card-content>
<div fxLayout="row" fxLayoutAlign="start none">
<div formArrayName="business_assets_details" fxFill>
<div *ngFor="let sup of _businessAssetsQuesFrom.controls.business_assets_details['controls']; let i=index; let last=last;">
<div
*ngFor="let sup of _businessAssetsQuesFrom.controls.business_assets_details['controls']; let i=index; let last=last;">
<mat-card>
<mat-card-content>
<div [formGroupName]="i">
<div fxLayout="row wrap" fxLayoutGap="5px" fxLayoutAlign="start none">
<mat-form-field style="width:100%">
<mat-select (selectionChange)="selectedAssetsType($event,i);setRequiredValidation($event.value,sup,2);" placeholder="Asset Type"
formControlName="business_assets_mode" requried>
<mat-select
(selectionChange)="selectedAssetsType($event,i);setRequiredValidation($event.value,sup,2);"
placeholder="Asset Type" formControlName="business_assets_mode" requried>
<mat-option>Select</mat-option>
<mat-option *ngFor="let asset of m_assets_type" [value]="asset.id" [disabled]="asset.flag!=1">{{
<mat-option *ngFor="let asset of m_assets_type" [value]="asset.id"
[disabled]="asset.flag!=1">{{
asset.name | titlecase }}</mat-option>
</mat-select>
</mat-form-field>
@ -193,7 +226,8 @@
<!--Property-->
<div *ngIf="sup.get('business_assets_mode').value == 2">
<div *ngFor="let detail of sup['controls'].business_details['controls']; let s = index">
<div
*ngFor="let detail of sup['controls'].business_details['controls']; let s = index">
<div [formGroupName]="s">
<div fxLayout="row" fxLayoutGap="2px" fxLayoutAlign="start none">
@ -201,20 +235,31 @@
<mat-select placeholder="Property Type" formControlName="property_type"
(selectionChange)="setRequiredValidation($event.value,detail,6)">
<mat-option>Select</mat-option>
<mat-option *ngFor="let m_address_type of m_address_type" [value]="m_address_type.address_type_id">
<mat-option *ngFor="let m_address_type of m_address_type"
[value]="m_address_type.address_type_id">
{{m_address_type.address_type}} </mat-option>
<!-- <mat-option *ngFor="let prop of m_propertyType" [value]="prop.id">{{ prop.name | titlecase }}</mat-option> -->
</mat-select>
</mat-form-field>
<mat-form-field style="width:45%" *ngIf="detail.get('property_type').value == 1">
<input matInput placeholder="Specify Other Property Type" formControlName="other_property_type"
autocomplete="off">
<mat-error *ngIf="detail.controls['other_property_type'].hasError('required')">Property Type Required</mat-error>
<mat-form-field style="width:45%"
*ngIf="detail.get('property_type').value == 1">
<input matInput placeholder="Specify Other Property Type"
formControlName="other_property_type" autocomplete="off">
<mat-error
*ngIf="detail.controls['other_property_type'].hasError('required')">Property
Type Required</mat-error>
</mat-form-field>
<mat-form-field style="width:45%" *ngIf="detail.get('property_type').value != ''">
<input matInput placeholder="Address of the Property" formControlName="address_of_the_property"
autocomplete="off">
<mat-error *ngIf="detail.controls['address_of_the_property'].hasError('required')">Address of the Property Required</mat-error>
<mat-form-field style="width:45%"
*ngIf="detail.get('property_type').value != ''">
<input matInput placeholder="Address of the Property"
formControlName="address_of_the_property"
(change)="addOptionOnAutoComplete(detail.get('property_type').value,$event.target.value,i)"
[matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let address of addressList" [value]="address.value">
<span>{{address.value}}</span>
</mat-option>
</mat-autocomplete>
</mat-form-field>
</div>
</div>
@ -223,7 +268,8 @@
<!--vehicle-->
<div *ngIf="sup.get('business_assets_mode').value == 3">
<div *ngFor="let detail of sup['controls'].business_details['controls']; let s = index">
<div
*ngFor="let detail of sup['controls'].business_details['controls']; let s = index">
<div [formGroupName]="s">
<div fxLayout="row" fxLayoutGap="2px" fxLayoutAlign="start none">
@ -231,15 +277,17 @@
<mat-select placeholder="Type of Vehicle" formControlName="vehicle_type"
(selectionChange)="setRequiredValidation($event.value,detail,5)">
<mat-option>Select</mat-option>
<mat-option *ngFor="let vehicle of m_vehicle_type" [value]="vehicle.vehicle_type_id">{{
<mat-option *ngFor="let vehicle of m_vehicle_type"
[value]="vehicle.vehicle_type_id">{{
vehicle.vehicle_type_name }}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width:45%" *ngIf="detail.get('vehicle_type').value == 1">
<input matInput placeholder=" Specify Vehicle" formControlName="other_vehicle_type"
autocomplete="off">
<mat-error *ngIf="detail.controls['other_vehicle_type'].hasError('required')">Vehicle Required</mat-error>
<input matInput placeholder=" Specify Vehicle"
formControlName="other_vehicle_type" autocomplete="off">
<mat-error *ngIf="detail.controls['other_vehicle_type'].hasError('required')">
Vehicle Required</mat-error>
</mat-form-field>
<mat-form-field style="width:45%">
@ -253,12 +301,14 @@
<!-- Eqipment Manufacturing -->
<div *ngIf="sup.get('business_assets_mode').value == 4">
<div *ngFor="let detail of sup['controls'].business_details['controls']; let s = index">
<div
*ngFor="let detail of sup['controls'].business_details['controls']; let s = index">
<div [formGroupName]="s">
<div fxLayout="row" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field style="width:95%">
<input matInput placeholder="Description" formControlName="equipment_manufacturing_description">
<input matInput placeholder="Description"
formControlName="equipment_manufacturing_description">
</mat-form-field>
</div>
@ -268,13 +318,15 @@
<!--other assets-->
<div *ngIf="sup.get('business_assets_mode').value == 1">
<div *ngFor="let detail of sup['controls'].business_details['controls']; let s = index">
<div
*ngFor="let detail of sup['controls'].business_details['controls']; let s = index">
<div [formGroupName]="s">
<div fxLayout="row" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field style="width:95%">
<input matInput placeholder="Description of the Assets" formControlName="any_other_assets"
autocomplete="off" required>
<mat-error *ngIf="detail.controls['any_other_assets'].hasError('required')">Asset's Description Required</mat-error>
<input matInput placeholder="Description of the Assets"
formControlName="any_other_assets" autocomplete="off" required>
<mat-error *ngIf="detail.controls['any_other_assets'].hasError('required')">
Asset's Description Required</mat-error>
</mat-form-field>
</div>
</div>
@ -292,60 +344,80 @@
<mat-option value="owned">Owned</mat-option>
<mat-option value="rented">Rented</mat-option>
</mat-select>
<mat-error *ngIf="sup.controls['business_ownership_type'].hasError('required')">Ownership Type Required</mat-error>
<mat-error *ngIf="sup.controls['business_ownership_type'].hasError('required')">
Ownership Type Required</mat-error>
</mat-form-field>
<mat-form-field style="width:45%" *ngIf="(sup.get('business_assets_mode').value != '' && sup.get('business_ownership_type').value == 'rented')">
<input matInput placeholder="Monthly Rent Amount" formControlName="business_monthly_rented_amt"
OnlyNumber type="text">
<mat-hint align="start" style="font-size:90%" *ngIf="sup.get('business_monthly_rented_amt').value != ''">{{"&#8377;"}} {{sup.get('business_monthly_rented_amt').value | numberToWords}} Only</mat-hint>
<mat-error *ngIf="sup.controls['business_monthly_rented_amt'].hasError('required')">Monthly Rent Amount Required</mat-error>
<mat-form-field style="width:45%"
*ngIf="(sup.get('business_assets_mode').value != '' && sup.get('business_ownership_type').value == 'rented')">
<input matInput placeholder="Monthly Rent Amount"
formControlName="business_monthly_rented_amt" OnlyNumber type="text">
<mat-hint align="start" style="font-size:90%"
*ngIf="sup.get('business_monthly_rented_amt').value != ''">{{"&#8377;"}}
{{sup.get('business_monthly_rented_amt').value | numberToWords}} Only</mat-hint>
<mat-error *ngIf="sup.controls['business_monthly_rented_amt'].hasError('required')">
Monthly Rent Amount Required</mat-error>
</mat-form-field>
</div>
<div fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none" *ngIf="sup.get('business_assets_mode').value != '' && sup.get('business_ownership_type').value == 'owned'">
<div fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none"
*ngIf="sup.get('business_assets_mode').value != '' && sup.get('business_ownership_type').value == 'owned'">
<mat-form-field style="width:45%">
<input matInput placeholder="Approximate Market Value" formControlName="business_approximate_market_value"
OnlyNumber type="text" autocomplete="off">
<mat-hint align="start" style="font-size:90%" *ngIf="sup.get('business_approximate_market_value').value != ''">{{"&#8377;"}} {{sup.get('business_approximate_market_value').value | numberToWords}} Only</mat-hint>
<mat-error *ngIf="sup.controls['business_approximate_market_value'].hasError('required')">Approximate Market Value Required</mat-error>
<input matInput placeholder="Approximate Market Value"
formControlName="business_approximate_market_value" OnlyNumber type="text"
autocomplete="off">
<mat-hint align="start" style="font-size:90%"
*ngIf="sup.get('business_approximate_market_value').value != ''">{{"&#8377;"}}
{{sup.get('business_approximate_market_value').value | numberToWords}} Only
</mat-hint>
<mat-error
*ngIf="sup.controls['business_approximate_market_value'].hasError('required')">
Approximate Market Value Required</mat-error>
</mat-form-field>
<mat-form-field style="width:45%">
<mat-select multiple placeholder="Asset Owned by" formControlName="business_name_of_the_owner"
[compareWith]="compareObjects" (selectionChange)="setOtherOwnerOfAsset($event.value,i)">
<mat-select multiple placeholder="Asset Owned by"
formControlName="business_name_of_the_owner" [compareWith]="compareObjects"
(selectionChange)="setOtherOwnerOfAsset($event.value,i)">
<mat-optgroup *ngFor="let group of mergeCompanyApplicant" [label]="group.groupName">
<mat-option *ngFor="let val of group.groupValues" [value]="val">
{{val.group_id != 2 ? val.name : val.name | titlecase}}
{{val.group_id != 2 ? val.name : val.name | titlecase}}
</mat-option>
</mat-optgroup>
</mat-select>
<mat-error *ngIf="sup.controls['business_name_of_the_owner'].hasError('required')">Asset Owned by is Required</mat-error>
<mat-error *ngIf="sup.controls['business_name_of_the_owner'].hasError('required')">
Asset Owned by is Required</mat-error>
</mat-form-field>
<mat-form-field *ngIf="isOtherOwner[i]" style="width:45%">
<input matInput placeholder="Specify Asset Owned Name" formControlName="business_name_of_the_other_owner"
autocomplete="off" [value]="sup.get('business_name_of_the_other_owner').value | titlecase">
<mat-error *ngIf="sup.controls['business_name_of_the_other_owner'].hasError('required')">Asset Owned by is Required</mat-error>
<input matInput placeholder="Specify Asset Owned Name"
formControlName="business_name_of_the_other_owner" autocomplete="off"
[value]="sup.get('business_name_of_the_other_owner').value | titlecase">
<mat-error
*ngIf="sup.controls['business_name_of_the_other_owner'].hasError('required')">Asset
Owned by is Required</mat-error>
</mat-form-field>
<mat-form-field style="width:45%">
<mat-label>Age of Asset in Years</mat-label>
<input matInput autocomplete="off" placeholder="eg.99" formControlName="business_vintage"
minlength="1" maxlength="2" OnlyNumber type="text" (keyup)="calculateVintagePurchase($event.target.value,i,1)">
<input matInput autocomplete="off" placeholder="eg.99"
formControlName="business_vintage" minlength="1" maxlength="2" OnlyNumber
type="text" (keyup)="calculateVintagePurchase($event.target.value,i,1)">
<!-- <mat-error> Invalid format</mat-error> -->
</mat-form-field>
<mat-form-field style="width:45%">
<mat-label>Purchase Year</mat-label>
<input matInput autocomplete="off" placeholder="YYYY eg.2018" formControlName="business_purchase_year"
minlength="4" maxlength="4" OnlyNumber type="text" (keyup)="calculateVintagePurchase($event.target.value,i,2)">
<input matInput autocomplete="off" placeholder="YYYY eg.2018"
formControlName="business_purchase_year" minlength="4" maxlength="4" OnlyNumber
type="text" (keyup)="calculateVintagePurchase($event.target.value,i,2)">
<!-- <mat-error> Invalid year format</mat-error> -->
</mat-form-field>
</div>
<span *ngIf="(sup.get('business_assets_mode').value != '') && sup.get('business_ownership_type').value == 'owned'">
<span
*ngIf="(sup.get('business_assets_mode').value != '') && sup.get('business_ownership_type').value == 'owned'">
<div fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field style="width:95%">
<mat-select placeholder="Is There a Loan Existing Against This Asset?"
@ -361,15 +433,16 @@
</mat-card-content>
<mat-card-actions>
<div align="right">
<button type="button" mat-raised-button mat-icon-button *ngIf="_businessAssetsQuesFrom.controls.business_assets_details.controls.length > 1"
<button type="button" mat-raised-button mat-icon-button
*ngIf="_businessAssetsQuesFrom.controls.business_assets_details.controls.length > 1"
(click)="removeAssetsDetails(i)" matTooltip="Delete Business Assets"
matTooltipPosition="above" class="mr-1 mb-1 hover-icon">
<mat-icon>delete</mat-icon>
</button>
</div>
<div align="center">
<button type="button" mat-flat-button (click)="addAssetDetails($event); false" matTooltip="Add More"
matTooltipPosition="left" color="primary" *ngIf="last">
<button type="button" mat-flat-button (click)="addAssetDetails($event); false"
matTooltip="Add More" matTooltipPosition="left" color="primary" *ngIf="last">
<strong>Add More Business Asset </strong>
</button>
</div>
@ -385,42 +458,45 @@
</ng-template>
</mat-tab>
<mat-tab label="Docs">
<ng-template matTabContent>
<div ngxViewer *ngIf="documentsAndFilesList.length>0; else noFiles">
<div fxLayout="row wrap" style="padding:20px;">
<div fxFlex="100">
<div fxFlex="20" class="m-gap p-gap" *ngFor="let doc of documentsAndFilesList">
<div class="p-list-main mb-2" style="width: 60%;height: auto;" *ngIf="doc.document_type != 'pdf'">
<div class="p-list">
<div class="top"> <img src="{{doc.document}}" alt="{{doc.document_name}}"style="width: 100%;height: 100%;">
<label *ngIf="doc.document_title != ''" style="font-size: 0.85rem">{{doc.document_title}}</label></div>
</div>
</div>
</div>
<ng-template matTabContent>
<div ngxViewer *ngIf="documentsAndFilesList.length>0; else noFiles">
<div fxLayout="row wrap" style="padding:20px;">
<div fxFlex="100">
<div fxFlex="20" class="m-gap p-gap" *ngFor="let doc of documentsAndFilesList">
<div class="p-list-main mb-2" style="width: 60%;height: auto;" *ngIf="doc.document_type != 'pdf'">
<div class="p-list">
<div class="top"> <img src="{{doc.document}}" alt="{{doc.document_name}}"
style="width: 100%;height: 100%;">
<label *ngIf="doc.document_title != ''"
style="font-size: 0.85rem">{{doc.document_title}}</label></div>
</div>
</div>
<div fxFlex="row">
<div fxFlex="100" class="m-gap p-gap">
<div fxLayout="row" fxLayoutWrap="wrap">
<div *ngFor="let doc of documentsAndFilesList">
<div class="text-center mb-2 hover-icon" fxFlex.xs="50" fxFlex.sm="50" fxFlex.md="20"
fxFlex.lg="20" fxFlex.xl="20" *ngIf="doc.document_type == 'pdf';">
<!-- <a href="http://www.google.com" target="_blank"> -->
<mat-icon style="color: #e00201;font-size: 60px !important;width:inherit !important;" (click)="pdf(doc.document)">picture_as_pdf</mat-icon>
<span class="d-block">{{doc.document_title}}</span>
<!-- </a> -->
</div>
</div>
</div>
</div>
</div>
<div fxFlex="row">
<div fxFlex="100" class="m-gap p-gap">
<div fxLayout="row" fxLayoutWrap="wrap">
<div *ngFor="let doc of documentsAndFilesList">
<div class="text-center mb-2 hover-icon" fxFlex.xs="50" fxFlex.sm="50" fxFlex.md="20"
fxFlex.lg="20" fxFlex.xl="20" *ngIf="doc.document_type == 'pdf';">
<!-- <a href="http://www.google.com" target="_blank"> -->
<mat-icon style="color: #e00201;font-size: 60px !important;width:inherit !important;"
(click)="pdf(doc.document)">picture_as_pdf</mat-icon>
<span class="d-block">{{doc.document_title}}</span>
<!-- </a> -->
</div>
</div>
</div>
</div>
</div>
</div>
<ng-template #noFiles>
<mat-card-content>
<p style="margin: 20px;">No Files</p>
</mat-card-content>
</ng-template>
</div>
<ng-template #noFiles>
<mat-card-content>
<p style="margin: 20px;">No Files</p>
</mat-card-content>
</ng-template>
</ng-template>
</mat-tab>
</mat-tab-group>
</mat-dialog-content>
@ -429,12 +505,13 @@
<div fxFlex="60" class="pb-0 text-sm-left" align="left">
<mat-form-field appearance="outline" style="width: 100%">
<mat-label>Remarks</mat-label>
<textarea matInput placeholder="Remarks" formControlName="business_assets_form_remark" autocomplete="off"></textarea>
<textarea matInput placeholder="Remarks" formControlName="business_assets_form_remark"
autocomplete="off"></textarea>
</mat-form-field>
</div>
<div fxFlex="40" align="end">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Save" matTooltipPosition="above"
type="submit">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Save"
matTooltipPosition="above" type="submit">
<mat-icon>save</mat-icon>
</button>
</div>

View File

@ -44,12 +44,12 @@ export class BusinessAssetsInfoComponent implements OnInit {
yearErrorMessage: any = [];
monthErrorMessage: any = [];
currentYear: any = new Date().getFullYear();
addressLabel: any = [];
// addressLabel: any = [];
addressList: any = [];
/**Declaration of Dropdown And Array */
public applicants: any;
public m_any_asset_loan_type = [{ 'value': "yes", 'viewValue': "Yes" },
{ 'value': "no", 'viewValue': "No" }]
public m_any_asset_loan_type = [{ 'value': "yes", 'viewValue': "Yes" }, { 'value': "no", 'viewValue': "No" }]
public m_assets_type = [];
public m_propertyType = [];
public m_address_type = [];
@ -63,7 +63,7 @@ export class BusinessAssetsInfoComponent implements OnInit {
existCompanyList: any = [];
mergeCompanyApplicant: any = [];
endUserList = [];
address_type : any ;
address_type: any;
/**Constructor of the class */
constructor(
notifier: NotifierService,
@ -89,7 +89,8 @@ export class BusinessAssetsInfoComponent implements OnInit {
documentsAndFilesList: any = [];
/** init Function */
ngOnInit() {
console.clear();
console.clear();
// this.pdTrigerService.getTypeofActivityForSuppliedInfoForm(this.pdid,'').subscribe(data => {
// this.businessProfessionName = (data.status == 200) ? data.records.profession_name : '' ;
// });
@ -114,7 +115,8 @@ export class BusinessAssetsInfoComponent implements OnInit {
this.mergeCompanyApplicant.push({ groupName: 'APPLICANTS', groupValues: modifyApplicantList })
}
})
});
this.getM_State_For_Address();
this.getPdSupplierFormDetails();
this.getM_Assets_Type();
@ -122,29 +124,32 @@ export class BusinessAssetsInfoComponent implements OnInit {
this.getM_Address_Type();
this.getM_Vehicle_Type();
this.getM_Address_Type();
this.pdTrigerService.retriveFile(this.pdid,'22',this.company_id).subscribe(data => {
if (data.status == 200) {
if(data.records.length>0){
data.records.forEach((val, index) => {
let splitted = val.pd_document_name.split(".");
let DocumentsAndFiles = {
'document_name': val.pd_document_name,
'document_title': val.pd_document_title,
'document': val.doc_url,
'document_type' : splitted[1] == 'pdf'?'pdf':'image'
}
this.documentsAndFilesList.push(DocumentsAndFiles);
});
}
}
else{
this.documentsAndFilesList = [];
}
});
}
getM_State_For_Address(){
this.pdTrigerService.retriveFile(this.pdid, '22', this.company_id).subscribe(data => {
if (data.status == 200) {
if (data.records.length > 0) {
data.records.forEach((val, index) => {
let splitted = val.pd_document_name.split(".");
let DocumentsAndFiles = {
'document_name': val.pd_document_name,
'document_title': val.pd_document_title,
'document': val.doc_url,
'document_type': splitted[1] == 'pdf' ? 'pdf' : 'image'
}
this.documentsAndFilesList.push(DocumentsAndFiles);
});
}
}
else {
this.documentsAndFilesList = [];
}
});
}
/** init Function Ends Here */
/** State Master For Addresses */
getM_State_For_Address() {
this.pdTrigerService.getAllMasterDatas('STATE').subscribe(
data => {
this.m_state_for_address = data.records.filter(data => data.isactive == 1);
@ -192,9 +197,10 @@ export class BusinessAssetsInfoComponent implements OnInit {
this.m_vehicle_type = data.records.filter(data => data.is_active == 1);
})
}
//Get Data Based on PDID and FORMID
apiLoadFinish: boolean = false;
getPdSupplierFormDetails() {
let reqparams: any = {};
reqparams.parent_pdid = this.parent_pdid;
@ -214,10 +220,10 @@ export class BusinessAssetsInfoComponent implements OnInit {
} else {
// this.noRecordFound = true;
}
}
);
});
}
loadaddresses() {
loadaddresses(flag) {
let params: any = {};
params.parent_pdid = this.parent_pdid;
@ -227,71 +233,118 @@ export class BusinessAssetsInfoComponent implements OnInit {
this.pdTrigerService.retriveForm(params).subscribe(data => {
if (data.status == 200) {
if(flag == 1){
let initiated_address_check = data.records.hasOwnProperty('is_pd_done_on_initiated_address') ? data.records.is_pd_done_on_initiated_address : true;
this.addressList.push({ key_name: 'initiate_address', value: data.records.addresses[0].address, description: 'Initiated Address' });
if (initiated_address_check == false ) {
this.addressList.push({ key_name: 'alternative_addresses', value: data.records.alternative_addresses[0].alternative_address, description: 'Alternative Address' });
}
}
else if(flag == 2){
let dataOfAddress = data.records.addresses.filter(item => item.isactive == 1);
this.addressList.push({ key_name: 'initiate_address', value: data.records.addresses[0].address, description: 'Initiated Address' });
let initiated_address_check = data.records.hasOwnProperty('is_pd_done_on_initiated_address') ? data.records.is_pd_done_on_initiated_address : true;
// // const control = <FormArray>this._businessAssetsQuesFrom.controls['business_assets_for_address'];
if (data.records.addresses.length > 0) {
if (initiated_address_check == true && data.records.addresses.length > 0) {
data.records.addresses.forEach((dataValue, inx) => {
this.addressLabel[inx] = '';
this.pdTrigerService.getStateWiseCities(dataValue.state).subscribe(data => {
if (data.status == 200) {
this.cityArr = data.records.cities;
this.pinArr = data.records.pincode;
let selectedAddressType = this.m_address_type.filter(element => element.address_type_id == dataValue.address_type)[0];
let selectedState = this.m_state_for_address.filter(element => element.state_id == dataValue.state)[0];
let selectedCity = this.cityArr.filter(element => element.city_id == dataValue.city)[0];
let selectedPincode = this.pinArr.filter(element => element.pincode_id == dataValue.pincode)[0];
let addressType = dataValue.address_type != 1 ? selectedAddressType.address_type : dataValue.address_type_others;
this.address_type = addressType;
let address = dataValue.address + ' , ' + selectedCity.city_name + ','+selectedState.name +'-' + (dataValue.pincode == 1 ? dataValue.pincode_others : selectedPincode.pincode);
this.placeholderName[inx] = 'Was any business activity seen at the ' + addressType + ' during PD visit?';
let addressLabel = address + ' / ' + addressType;
let vals = {
address_label: addressLabel,
business_years: '',
business_month: '',
business_address_availability: '',
business_is_pd_visited: '',
business_pd_visited_remark: '',
business_approximate_market_value: '',
business_ownership_type: '',
business_monthly_rented_amt: '',
business_name_of_the_owner: '',
business_name_of_the_other_owner: '',
business_vintage: '',
business_purchase_year: '',
business_emi: ''
}
const control = <FormArray>this._businessAssetsQuesFrom.controls['business_assets_for_address'];
control.push(this.initBusinessAddressDetailsWithdata(vals));
this.cityArr = data.records.cities;
this.pinArr = data.records.pincode;
let selectedAddressType = this.m_address_type.filter(element => element.address_type_id == dataValue.address_type)[0];
let selectedState = this.m_state_for_address.filter(element => element.state_id == dataValue.state)[0];
let selectedCity = this.cityArr.filter(element => element.city_id == dataValue.city)[0];
let selectedPincode = this.pinArr.filter(element => element.pincode_id == dataValue.pincode)[0];
let addressType = dataValue.address_type != 1 ? selectedAddressType.address_type : dataValue.address_type_others;
this.address_type = addressType;
let address = dataValue.address + ' , ' + selectedCity.city_name + ',' + selectedState.name + '-' + (dataValue.pincode == 1 ? dataValue.pincode_others : selectedPincode.pincode);
this.placeholderName[inx] = 'Was any business activity seen at the ' + addressType + ' during PD visit?';
let addressLabel = address + ' / ' + addressType;
let vals = {
address_label: addressLabel,
business_years: '',
business_month: '',
business_address_availability: '',
business_is_pd_visited: '',
business_pd_visited_remark: '',
business_approximate_market_value: '',
business_ownership_type: '',
business_monthly_rented_amt: '',
business_name_of_the_owner: '',
business_name_of_the_other_owner: '',
business_vintage: '',
business_purchase_year: '',
business_emi: ''
}
const control = <FormArray>this._businessAssetsQuesFrom.controls['business_assets_for_address'];
control.push(this.initBusinessAddressDetailsWithdata(vals));
}
});
});
}
else {
} else if (initiated_address_check == false && data.records.alternative_addresses.length > 0) {
this.addressList.push({ key_name: 'alternative_addresses', value: data.records.alternative_addresses[0].alternative_address, description: 'Alternative Address' });
data.records.alternative_addresses.forEach((dataValue, inx) => {
this.pdTrigerService.getStateWiseCities(dataValue.alternative_state).subscribe(data => {
if (data.status == 200) {
this.cityArr = data.records.cities;
this.pinArr = data.records.pincode;
let selectedAddressType = this.m_address_type.filter(element => element.address_type_id == dataValue.address_type)[0];
let selectedState = this.m_state_for_address.filter(element => element.state_id == dataValue.alternative_state)[0];
let selectedCity = this.cityArr.filter(element => element.city_id == dataValue.alternative_city)[0];
let selectedPincode = this.pinArr.filter(element => element.pincode_id == dataValue.alternative_pincode)[0];
let addressType = dataValue.address_type != 1 ? selectedAddressType.address_type : dataValue.address_type_others;
this.address_type = addressType;
let address = dataValue.alternative_address + ' , ' + selectedCity.city_name + ',' + selectedState.name + '-' + (dataValue.alternative_pincode == 1 ? dataValue.alternative_pincode_others : selectedPincode.pincode);
this.placeholderName[inx] = 'Was any business activity seen at the ' + addressType + ' during PD visit?';
let addressLabel = address + ' / ' + addressType;
let vals = {
address_label: addressLabel,
business_years: '',
business_month: '',
business_address_availability: '',
business_is_pd_visited: '',
business_pd_visited_remark: '',
business_approximate_market_value: '',
business_ownership_type: '',
business_monthly_rented_amt: '',
business_name_of_the_owner: '',
business_name_of_the_other_owner: '',
business_vintage: '',
business_purchase_year: '',
business_emi: ''
}
const control = <FormArray>this._businessAssetsQuesFrom.controls['business_assets_for_address'];
control.push(this.initBusinessAddressDetailsWithdata(vals));
}
});
});
} else {
const control = <FormArray>this._businessAssetsQuesFrom.controls['business_assets_for_address'];
control.push(this.initBusinessAddressDetails());
}
}
}}
else {
const control = <FormArray>this._businessAssetsQuesFrom.controls['business_assets_for_address'];
control.push(this.initBusinessAddressDetails());
}
});
}
// business_years: [value.business_years],
// business_month: [value.business_month],
// business_address_availability: [value.business_address_availability],
// business_is_pd_visited: [value.business_is_pd_visited],
// business_pd_visited_remark: [value.business_pd_visited_remark],
// business_assets_for_address: this._formBuilder.array([]),
// business_years: [''],
// business_month: [''],
// business_address_availability: [''],
@ -303,6 +356,7 @@ export class BusinessAssetsInfoComponent implements OnInit {
formLoadData(val) {
if (val !== null) {
let value = val;
this.loadaddresses(1);
this._businessAssetsQuesFrom = this._formBuilder.group({
parent_pdid: [this.parent_pdid],
pdid: [this.pdid],
@ -333,7 +387,7 @@ export class BusinessAssetsInfoComponent implements OnInit {
business_assets_details: this._formBuilder.array([this.initBusinessDetails()]),
business_assets_form_remark: ['']
});
this.loadaddresses();
this.loadaddresses(2);
}
this.loadDetails = true;
}
@ -364,7 +418,7 @@ export class BusinessAssetsInfoComponent implements OnInit {
address_label: [''],
business_years: [''],
business_month: [''],
business_address_availability: ['',Validators.compose([Validators.required])],
business_address_availability: ['', Validators.compose([Validators.required])],
business_is_pd_visited: [''],
business_pd_visited_remark: [''],
// this.createBusinessAssetsForAddress()
@ -438,6 +492,7 @@ export class BusinessAssetsInfoComponent implements OnInit {
break;
}
}
this.removeOptionOnAutoComplete(i);
}
loadEquipmentManufacturingDescription() {
@ -459,17 +514,15 @@ export class BusinessAssetsInfoComponent implements OnInit {
manufacturer_model_vehicle: [''],
vehicle_type: [''],
other_vehicle_type: ['']
});
}
otherBusinessAssetsDescription() {
return this._formBuilder.group({
any_other_assets: ['',Validators.compose([Validators.required])],
any_other_assets: ['', Validators.compose([Validators.required])],
});
}
loadPropertyWithData(data) {
return this._formBuilder.group({
property_type: [data.property_type],
@ -486,7 +539,7 @@ export class BusinessAssetsInfoComponent implements OnInit {
otherBusinessAssetsDescriptionWithData(data) {
return this._formBuilder.group({
any_other_assets: [data.any_other_assets,Validators.compose([Validators.required])],
any_other_assets: [data.any_other_assets, Validators.compose([Validators.required])],
});
}
@ -595,29 +648,31 @@ export class BusinessAssetsInfoComponent implements OnInit {
var result = Object.keys(data).map(function (key) {
return data[key];
});
if (result.length > 0) {
result.forEach((datas, index) => {
let Avaliablity = 1;
if (datas.business_name_of_the_owner !== null) {
if (datas.business_name_of_the_owner.length > 0) {
datas.business_name_of_the_owner.forEach(option => {
if (option.id == 0 && option.group_id == 2) {
Avaliablity = option.id;
}
});
}}
if (datas.business_name_of_the_owner.length > 0) {
datas.business_name_of_the_owner.forEach(option => {
if (option.id == 0 && option.group_id == 2) {
Avaliablity = option.id;
}
});
}
}
this.isOtherOwnerForAddress[index] = Avaliablity == 0 ? true : false;
});
// for (let val of result) {
result.forEach((val, index) => {
var splitted_label = val.address_label.split("/", 2);
var splitted_label = val.address_label.split("/", 2);
let addressType = splitted_label[1] != '' ? splitted_label[1] : 'Address Type';
this.placeholderName[index] = 'Was any business activity seen at the ' + addressType + ' during PD visit?';
this.address_type = addressType;
this.placeholderName[index] = 'Was any business activity seen at the ' + addressType + ' during PD visit?';
this.address_type = addressType;
let vals = {
address_label: val.address_label,
business_years: val.business_years,
@ -652,18 +707,17 @@ export class BusinessAssetsInfoComponent implements OnInit {
if (result.length > 0) {
result.forEach((datas, index) => {
let Avaliablity = 1;
if(datas.business_name_of_the_owner !== null){
if (datas.business_name_of_the_owner.length > 0) {
datas.business_name_of_the_owner.forEach(option => {
if (option.id == 0 && option.group_id == 2) {
Avaliablity = option.id;
}
});
}}
if (datas.business_name_of_the_owner !== null) {
if (datas.business_name_of_the_owner.length > 0) {
datas.business_name_of_the_owner.forEach(option => {
if (option.id == 0 && option.group_id == 2) {
Avaliablity = option.id;
}
});
}
}
this.isOtherOwner[index] = Avaliablity == 0 ? true : false;
});
for (let val of result) {
@ -688,7 +742,6 @@ if(datas.business_name_of_the_owner !== null){
}
setBusinessAssetsDetailsWithData(assets_details_mode: any, datas: any, i: any): void {
let val = i;
let data = datas;
@ -709,6 +762,7 @@ if(datas.business_name_of_the_owner !== null){
let business_property_datas: any;
data.forEach((datas, i) => {
business_property_datas = { 'property_type': datas.property_type, 'other_property_type': datas.other_property_type, 'address_of_the_property': datas.address_of_the_property };
this.addOptionOnAutoComplete(datas.property_type, datas.address_of_the_property, val);
});
const control = (<FormArray>this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray;
control.push(this.loadPropertyWithData(business_property_datas));
@ -738,6 +792,39 @@ if(datas.business_name_of_the_owner !== null){
}
}
addOptionOnAutoComplete(property_id, event, i) {
if(event != ''){
let getList = this.addressList.map(dval => dval.value.replace(/\s/g, "").toLowerCase());
let getkeyname = this.addressList.map(dval => dval.key_name);
let findName = this.m_address_type.find(x => x.address_type_id == property_id);
// console.log(getkeyname.indexOf(i));
let evt = event.replace(/\s/g, "").toLowerCase();
let keyexist = this.addressList.find(ob => ob['key_name'] === i);
if (keyexist === undefined || keyexist === null && !getList.includes(evt)) {
console.log('push on this');
this.addressList.push({ key_name: i, value: event, description: findName.address_type + ' At Index ' + i });
}
else {
let Index = getkeyname.indexOf(i);
this.addressList[Index] = { key_name: i, value: event, description: findName.address_type + ' At Index ' + i }
console.log('update on this => Index', Index);
}
console.log('at Final add or update ', this.addressList);
}
}
removeOptionOnAutoComplete(i) {
let getkeyname = this.addressList.map(dval => dval.key_name);
let Index = getkeyname.indexOf(i);
if (Index !== -1) {
this.addressList.splice(Index, 1);
}
console.log('at Final remove', this.addressList);
}
/** Add More Asset using Flag Both "Other Asset" And "Business Asset" */
addAssetDetails(e) {
@ -890,9 +977,9 @@ if(datas.business_name_of_the_owner !== null){
let ParCtrls = <FormArray>this._businessAssetsQuesFrom.controls.business_assets_details;
let ChdCtrls: any = <FormArray>ParCtrls.controls[ParInx];
let Avaliablity = 1;
if (value !== null ) {
let Avaliablity = 1;
if (value !== null) {
if (value.length > 0) {
value.forEach(option => {
@ -902,23 +989,23 @@ if(datas.business_name_of_the_owner !== null){
});
}
}
if (Avaliablity == 0) {
ChdCtrls.controls.business_name_of_the_other_owner.setValidators([Validators.required]);
this.isOtherOwner[ParInx] = true;
} else if (Avaliablity == 1) {
ChdCtrls.controls.business_name_of_the_other_owner.setValue('');
ChdCtrls.controls.business_name_of_the_other_owner.clearValidators();
this.isOtherOwner[ParInx] = false;
}
ChdCtrls.controls.business_name_of_the_other_owner.updateValueAndValidity();
if (Avaliablity == 0) {
ChdCtrls.controls.business_name_of_the_other_owner.setValidators([Validators.required]);
this.isOtherOwner[ParInx] = true;
} else if (Avaliablity == 1) {
ChdCtrls.controls.business_name_of_the_other_owner.setValue('');
ChdCtrls.controls.business_name_of_the_other_owner.clearValidators();
this.isOtherOwner[ParInx] = false;
}
ChdCtrls.controls.business_name_of_the_other_owner.updateValueAndValidity();
}
@ -926,12 +1013,12 @@ if(datas.business_name_of_the_owner !== null){
setOtherOwnerOfAddress(value, ParInx) {
let ParCtrls = <FormArray>this._businessAssetsQuesFrom.controls.business_assets_for_address;
let ChdCtrls: any = <FormArray>ParCtrls.controls[ParInx];
let Avaliablity = 1;
if (value !== null ) {
if (value !== null) {
if (value.length > 0) {
value.forEach(option => {
@ -939,23 +1026,23 @@ if(datas.business_name_of_the_owner !== null){
Avaliablity = option.id;
}
});
}
}
if (Avaliablity == 0) {
ChdCtrls.controls.business_name_of_the_other_owner.setValidators([Validators.required]);
this.isOtherOwnerForAddress[ParInx] = true;
} else if (Avaliablity == 1) {
ChdCtrls.controls.business_name_of_the_other_owner.setValue('');
ChdCtrls.controls.business_name_of_the_other_owner.clearValidators();
this.isOtherOwnerForAddress[ParInx] = false;
}
ChdCtrls.controls.business_name_of_the_other_owner.updateValueAndValidity();
}
if (Avaliablity == 0) {
ChdCtrls.controls.business_name_of_the_other_owner.setValidators([Validators.required]);
this.isOtherOwnerForAddress[ParInx] = true;
} else if (Avaliablity == 1) {
ChdCtrls.controls.business_name_of_the_other_owner.setValue('');
ChdCtrls.controls.business_name_of_the_other_owner.clearValidators();
this.isOtherOwnerForAddress[ParInx] = false;
}
ChdCtrls.controls.business_name_of_the_other_owner.updateValueAndValidity();
}
@ -969,13 +1056,13 @@ if(datas.business_name_of_the_owner !== null){
item.controls.business_ownership_type.setValidators([Validators.required]);
}
else {
item.controls.business_years.setValue('');
item.controls.business_month.setValue('');
item.controls.business_is_pd_visited.setValue('');
item.controls.business_pd_visited_remark.setValue('');
item.controls.business_pd_visited_remark.setValue('');
item.controls.business_ownership_type.setValue('');
item.controls.business_years.clearValidators();
item.controls.business_is_pd_visited.clearValidators();
item.controls.business_pd_visited_remark.clearValidators();
@ -1006,12 +1093,14 @@ if(datas.business_name_of_the_owner !== null){
item.controls.business_ownership_type.updateValueAndValidity();
}
if(flag == 2){
if(value != ''){
item.controls.business_ownership_type.setValidators([Validators.required]);}
else{
item.controls.business_ownership_type.setValue('');
item.controls.business_ownership_type.clearValidators();}
if (flag == 2) {
if (value != '') {
item.controls.business_ownership_type.setValidators([Validators.required]);
}
else {
item.controls.business_ownership_type.setValue('');
item.controls.business_ownership_type.clearValidators();
}
item.controls.business_ownership_type.updateValueAndValidity();
}
if (flag == 3) {
@ -1072,10 +1161,9 @@ if(datas.business_name_of_the_owner !== null){
selectedAddressType(e: any) {
this.placeholderName = 'Was any business activity seen at the ' + e + ' during PD visit?';
}
pdf(fileURL){
pdf(fileURL) {
window.open(fileURL);
}
}
/** For Docs Tab */
public viewerOptions: any = {
navbar: false,