Fairoj : OLD SMC CREDIT PD CHANGES CURRENTLY NOT USE NOW.
This commit is contained in:
parent
2abcd4b511
commit
ddc5c79116
16
src/Shared/shared.module.ts
Normal file
16
src/Shared/shared.module.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { NgModule } from "@angular/core";
|
||||||
|
import { CommonModule } from "@angular/common";
|
||||||
|
import { NumToWordsPipe } from "../pipes/num-to-words/num-to-words";
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
NumToWordsPipe
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
NumToWordsPipe
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class SharedModule {}
|
||||||
@ -17,6 +17,7 @@ import { ConstantsProvider } from '../providers/constants/constants';
|
|||||||
import { SalesPdProvider } from '../pages/sales_pd/providers/sales-pd/sales-pd';
|
import { SalesPdProvider } from '../pages/sales_pd/providers/sales-pd/sales-pd';
|
||||||
import { PdtriggerProvider } from '../providers/pdtrigger/pdtrigger';
|
import { PdtriggerProvider } from '../providers/pdtrigger/pdtrigger';
|
||||||
import { ConnectionStatus, NetworkDetectionProvider } from '../providers/network-detection/network-detection';
|
import { ConnectionStatus, NetworkDetectionProvider } from '../providers/network-detection/network-detection';
|
||||||
|
import { CreditPdListPage } from '../pages/credit_pd/pages/credit-pd-list/credit-pd-list';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: 'app.html'
|
templateUrl: 'app.html'
|
||||||
@ -169,9 +170,15 @@ export class MyApp {
|
|||||||
let role= this.constant.takeDecisionRouting(this.userDetails)
|
let role= this.constant.takeDecisionRouting(this.userDetails)
|
||||||
if(role == 'sales'){
|
if(role == 'sales'){
|
||||||
this.pages[0].method=()=>this.menulist(3)
|
this.pages[0].method=()=>this.menulist(3)
|
||||||
|
this.pages=this.pages.filter(ele=>ele.title != 'Sales PD' && ele.title != 'Credit PD')
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.pages[0].method=()=>this.menulist(1)
|
this.pages[0].method=()=>this.menulist(1)
|
||||||
|
this.pages.splice(-1,1)
|
||||||
|
this.pages=this.pages.filter(ele=>ele.title != 'Sales PD' && ele.title != 'Credit PD')
|
||||||
|
this.pages.push( { title :'Sales PD',icon:'briefcase',method:()=>this.menulist(3)},
|
||||||
|
// { title :'Credit PD',icon:'list',method:()=>this.menulist(4)},
|
||||||
|
{ title: 'Logout', icon: 'md-exit',method:()=>this.menulist(2)})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -194,6 +201,7 @@ export class MyApp {
|
|||||||
this.nav.setRoot(SalesPDlistPage);
|
this.nav.setRoot(SalesPDlistPage);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
this.nav.setRoot(CreditPdListPage)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,6 +91,10 @@ import { OfflineManagerProvider } from '../pages/sales_pd/providers/offline-mana
|
|||||||
import { IonicStorageProvider } from '../providers/ionic-storage/ionic-storage';
|
import { IonicStorageProvider } from '../providers/ionic-storage/ionic-storage';
|
||||||
import { Network } from '@ionic-native/network';
|
import { Network } from '@ionic-native/network';
|
||||||
import {SocialSharing} from '@ionic-native/social-sharing'
|
import {SocialSharing} from '@ionic-native/social-sharing'
|
||||||
|
import { CreditSectionListPageModule } from '../pages/credit_pd/pages/credit-section-list/credit-section-list.module';
|
||||||
|
import { OfflineManagerCreditProvider } from '../pages/credit_pd/providers/offline-manager-credit/offline-manager-credit';
|
||||||
|
import { ApiServiceProvider } from '../pages/credit_pd/providers/api-service/api-service';
|
||||||
|
|
||||||
// need the hammerConnfig
|
// need the hammerConnfig
|
||||||
export class HammerConfig extends HammerGestureConfig {
|
export class HammerConfig extends HammerGestureConfig {
|
||||||
overrides = {
|
overrides = {
|
||||||
@ -120,7 +124,7 @@ export class HammerConfig extends HammerGestureConfig {
|
|||||||
SalesPDlistPage,
|
SalesPDlistPage,
|
||||||
ReportViewer,
|
ReportViewer,
|
||||||
AdvanceFilterPage,
|
AdvanceFilterPage,
|
||||||
PdAdvanceFilterPage
|
PdAdvanceFilterPage,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,ReactiveFormsModule,FormsModule,
|
BrowserModule,ReactiveFormsModule,FormsModule,
|
||||||
@ -163,6 +167,8 @@ export class HammerConfig extends HammerGestureConfig {
|
|||||||
ContentLoaderModule,
|
ContentLoaderModule,
|
||||||
PdfViewerModule,
|
PdfViewerModule,
|
||||||
|
|
||||||
|
CreditSectionListPageModule
|
||||||
|
|
||||||
],
|
],
|
||||||
bootstrap: [IonicApp],
|
bootstrap: [IonicApp],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
@ -206,9 +212,14 @@ export class HammerConfig extends HammerGestureConfig {
|
|||||||
NetworkDetectionProvider,
|
NetworkDetectionProvider,
|
||||||
OfflineManagerProvider,
|
OfflineManagerProvider,
|
||||||
IonicStorageProvider,
|
IonicStorageProvider,
|
||||||
|
OfflineManagerCreditProvider,
|
||||||
|
ApiServiceProvider,
|
||||||
|
|
||||||
],
|
],
|
||||||
// exports:[HomePageModule]
|
// exports:[HomePageModule]
|
||||||
|
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2194
src/assets/credit_pd_template.json
Normal file
2194
src/assets/credit_pd_template.json
Normal file
File diff suppressed because it is too large
Load Diff
60
src/pages/credit_pd/components/components.module.ts
Executable file
60
src/pages/credit_pd/components/components.module.ts
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { QuesTemplateComponent } from './ques-template/ques-template';
|
||||||
|
import { MatButtonToggleModule, MatCardModule, MatCheckboxModule, MatChipsModule, MatDatepickerModule, MatDialogModule, MatListModule, MatExpansionModule, MatGridListModule, MatIconModule, MatInputModule, MatMenuModule, MatNativeDateModule, MatPaginatorModule, MatProgressBarModule, MatProgressSpinnerModule, MatRadioModule, MatRippleModule, MatSelectModule, MatSidenavModule, MatSliderModule, MatSlideToggleModule, MatSnackBarModule, MatSortModule, MatTableModule, MatTabsModule, MatToolbarModule, MatTooltipModule, MatStepperModule, MatFormFieldModule, MatAutocompleteModule } from '@angular/material';
|
||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
import { IonicImageViewerModule } from 'ionic-img-viewer';
|
||||||
|
import { NgxMatSelectSearchModule } from 'ngx-mat-select-search';
|
||||||
|
import { ReactiveFormsModule } from '@angular/forms';
|
||||||
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
|
import { IonicModule } from 'ionic-angular';
|
||||||
|
import { MyApp } from '../../../app/app.component';
|
||||||
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
|
import { QuesServiceProvider } from '../../sales_pd/providers/ques-service/ques-service';
|
||||||
|
import { SharedModule } from '../../../Shared/shared.module';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [QuesTemplateComponent],
|
||||||
|
imports: [MatButtonToggleModule,
|
||||||
|
SharedModule,
|
||||||
|
BrowserModule,
|
||||||
|
IonicModule.forRoot(MyApp),
|
||||||
|
BrowserAnimationsModule,
|
||||||
|
MatAutocompleteModule,
|
||||||
|
MatCardModule,
|
||||||
|
MatCheckboxModule,
|
||||||
|
MatChipsModule,
|
||||||
|
MatDatepickerModule,
|
||||||
|
MatDialogModule,MatListModule,
|
||||||
|
MatExpansionModule,
|
||||||
|
MatGridListModule,
|
||||||
|
MatIconModule,
|
||||||
|
MatInputModule,
|
||||||
|
MatListModule,
|
||||||
|
MatMenuModule,
|
||||||
|
MatNativeDateModule,
|
||||||
|
MatPaginatorModule,
|
||||||
|
MatProgressBarModule,
|
||||||
|
MatProgressSpinnerModule,
|
||||||
|
MatRadioModule,
|
||||||
|
MatRippleModule,
|
||||||
|
MatSelectModule,
|
||||||
|
MatSidenavModule,
|
||||||
|
MatSliderModule,
|
||||||
|
MatSlideToggleModule,
|
||||||
|
MatSnackBarModule,
|
||||||
|
MatSortModule,
|
||||||
|
MatTableModule,
|
||||||
|
MatTabsModule,
|
||||||
|
MatToolbarModule,
|
||||||
|
MatTooltipModule,
|
||||||
|
MatStepperModule,HttpClientModule,IonicImageViewerModule,
|
||||||
|
MatFormFieldModule,
|
||||||
|
NgxMatSelectSearchModule,
|
||||||
|
ReactiveFormsModule],
|
||||||
|
exports: [QuesTemplateComponent],
|
||||||
|
providers:[ QuesServiceProvider
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class ComponentsModule {}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
export const photoJSONStructure ={"answer_value": "",
|
||||||
|
"question": "Approach to PD Location",
|
||||||
|
"question_key": "approach_to_pd_location",
|
||||||
|
"type": "6",
|
||||||
|
"raw_validations": [],
|
||||||
|
"validations": [],
|
||||||
|
"api_properties": null,
|
||||||
|
"onchange_properties": null,
|
||||||
|
"answers": null,
|
||||||
|
"is_repeatable": null,
|
||||||
|
"group_title": null,
|
||||||
|
"is_loader": "",
|
||||||
|
"is_saved": "",
|
||||||
|
"is_image_status": false}
|
||||||
394
src/pages/credit_pd/components/ques-template/ques-template.html
Executable file
394
src/pages/credit_pd/components/ques-template/ques-template.html
Executable file
@ -0,0 +1,394 @@
|
|||||||
|
<!-- Generated template for the QuesTemplateComponent component -->
|
||||||
|
<div *ngIf="questions_JSON.questions.length > 0" #whole_form>
|
||||||
|
<form [formGroup]="quesAnsForm" >
|
||||||
|
<div *ngIf="quesAnsForm.controls['questions']">
|
||||||
|
<div formArrayName="questions">
|
||||||
|
<div *ngFor="let parent_ques of quesAnsForm.controls['questions'].controls;let p_i=index">
|
||||||
|
<div [formGroupName]="p_i">
|
||||||
|
|
||||||
|
<div *ngIf="parent_ques.get('is_repeatable').value != '1'">
|
||||||
|
|
||||||
|
<mat-form-field style="width: 100%" *ngIf="parent_ques.get('type').value == '1'" [ngStyle]="{'margin-bottom':parent_ques.get('field_type').value == 'numtoword' ? '5%' : '0' }">
|
||||||
|
|
||||||
|
<mat-label>{{parent_ques.get('question').value}}</mat-label>
|
||||||
|
<input matInput [type]="parent_ques.get('field_type').value == 'num' || parent_ques.get('field_type').value == 'numtoword' ? 'number' : parent_ques.get('field_type').value == 'string' ? 'text' : parent_ques.get('field_type').value" formControlName="answer_value"
|
||||||
|
[placeholder]="parent_ques.get('place_holder').value"
|
||||||
|
autocomplete="off" (change)="onChangeProperty($event,parent_ques,'','',p_i)"
|
||||||
|
>
|
||||||
|
<!-- [placeholder]="parent_ques.get('field_type').value == 'num' || parent_ques.get('field_type').value == 'numtoword' ? 'Entert the Number' : 'Enter the Text'" -->
|
||||||
|
<mat-hint *ngIf="parent_ques.get('answer_value').value != '' && parent_ques.get('field_type').value == 'numtoword'" align="end" style="font-size: 12px;">{{"₹"}}{{parent_ques.get('answer_value').value | numToWords}}</mat-hint>
|
||||||
|
<!-- <mat-hint align="end" style="font-size: 11.5px;color: gray;" *ngIf="parent_ques.get('is_amt_in_words').value == true">One Lack</mat-hint> -->
|
||||||
|
<ng-container *ngFor="let validation of parent_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="parent_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container>
|
||||||
|
</mat-form-field>
|
||||||
|
<!-- <mat-form-field> -->
|
||||||
|
<div class="radio-gap" *ngIf="parent_ques.get('type').value == '2'">
|
||||||
|
<mat-label>{{parent_ques.get('question').value}}</mat-label><br/>
|
||||||
|
<mat-radio-group aria-label="Select an option" formControlName="answer_value" (change)="onChangeProperty($event,parent_ques,'','',p_i)">
|
||||||
|
<mat-radio-button class="radio-btn-gap" *ngFor="let val of parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-radio-button><br />
|
||||||
|
</mat-radio-group>
|
||||||
|
<ng-container *ngFor="let validation of parent_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="parent_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<mat-form-field style="width: 100%" *ngIf="parent_ques.get('type').value == '3'">
|
||||||
|
<mat-label>{{parent_ques.get('question').value}}</mat-label>
|
||||||
|
<mat-select formControlName="answer_value" (selectionChange)="onChangeProperty($event,parent_ques,'','',p_i)">
|
||||||
|
<mat-option *ngFor="let val of parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
|
||||||
|
<ng-container *ngFor="let validation of parent_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="parent_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<div class="radio-gap" formArrayName="answer_value" *ngIf="parent_ques.get('type').value == '5'">
|
||||||
|
<mat-label>{{parent_ques.get('question').value}}</mat-label>
|
||||||
|
<mat-checkbox class="radio-btn-gap" *ngFor="let val of parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer" (change)="onChange_checkbox($event,parent_ques)">{{val.answer}}</mat-checkbox><br />
|
||||||
|
<ng-container *ngFor="let validation of parent_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="parent_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<mat-form-field style="width: 100%" *ngIf="parent_ques.get('type').value == '4'">
|
||||||
|
<mat-label>{{parent_ques.get('question').value}}</mat-label>
|
||||||
|
<mat-select multiple formControlName="answer_value" (selectionChange)="onChangeProperty($event,parent_ques,'','',p_i)">
|
||||||
|
<mat-option *ngFor="let val of parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
|
||||||
|
<ng-container *ngFor="let validation of parent_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="parent_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<div *ngIf="parent_ques.get('type').value == '6'">
|
||||||
|
<ion-grid >
|
||||||
|
<ion-row>
|
||||||
|
<ion-col col-6 no-padding align-self: center text-center >
|
||||||
|
<div >
|
||||||
|
<img *ngIf="parent_ques.get('answer_value').value != ''" [src]="parent_ques.get('answer_value').value" imageViewer class="doc-image-bucket"><br/>
|
||||||
|
<label ><strong>{{parent_ques.get('question').value}}</strong></label>
|
||||||
|
<!-- <input *ngIf="image.Name =='' && image.option != 'dummy'" width="20px" ion-input type="text" placeholder="Document Name" (blur)="changeName($event.target.value,i,image.image)"> -->
|
||||||
|
<!-- <button *ngIf="image.option != 'dummy'" ion-button clear color="optblue" (click)="removeImg(i)"><ion-icon style="font-size:22px" name="md-trash"></ion-icon></button> -->
|
||||||
|
</div>
|
||||||
|
<ion-row style="justify-content: center">
|
||||||
|
<ion-col col-8>
|
||||||
|
<button ion-button clear color="optblue" [disabled]="sales_pd_type == '2'" (click)="captureImg(p_i,parent_ques)"><ion-icon style="font-size: 30px" name="md-camera"></ion-icon></button>
|
||||||
|
</ion-col>
|
||||||
|
<!-- IMAGE STATUS ICON FOR INPROGRESS, COMPLETED AND FAILED -->
|
||||||
|
<ion-col col-4 *ngIf="parent_ques.get('is_image_status').value == true">
|
||||||
|
<ion-spinner name="crescent" style="width: 20px;
|
||||||
|
height: 20px;" (click)="cancelLoader(parent_ques)"
|
||||||
|
*ngIf="parent_ques.get('is_loader').value == true"></ion-spinner>
|
||||||
|
<ion-icon style="color: #008828;float: right;
|
||||||
|
margin-right: 30%;" *ngIf="parent_ques.get('is_saved').value == true" name="checkmark-circle-outline"></ion-icon>
|
||||||
|
<span style="margin:0px;" *ngIf="(parent_ques.get('is_saved').value == false &&
|
||||||
|
parent_ques.get('is_loader').value == false) && (parent_ques.value.hasOwnProperty('is_saved') &&
|
||||||
|
parent_ques.value.hasOwnProperty('is_loader'))" (click)="imageReupload(parent_ques)">
|
||||||
|
<ion-row style="margin-top: -17px;padding:0px;"><button ion-button clear><ion-icon style="color:lightcoral;" name="refresh-circle"></ion-icon></button></ion-row>
|
||||||
|
<ion-row style="margin-top: -20px;padding:0px;"><p style="font-size: 10px">Click to ReUpload</p></ion-row>
|
||||||
|
</span>
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
<!-- <ng-container ngProjectAs="mat-hint">
|
||||||
|
<mat-error >Please capture the image</mat-error>
|
||||||
|
</ng-container> -->
|
||||||
|
</ion-col>
|
||||||
|
<hr/>
|
||||||
|
</ion-row>
|
||||||
|
|
||||||
|
</ion-grid>
|
||||||
|
<ng-container *ngFor="let validation of parent_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="parent_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container>
|
||||||
|
<!-- <ng-container ngProjectAs="mat-hint">
|
||||||
|
<mat-error align="end">Please capture the image</mat-error>
|
||||||
|
</ng-container> -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<mat-form-field style="width: 100%" *ngIf="parent_ques.get('type').value == '7'">
|
||||||
|
<mat-label>{{parent_ques.get('question').value}}</mat-label>
|
||||||
|
<textarea matInput type="text" rows="3" formControlName="answer_value" placeholder="Enter the Text"
|
||||||
|
autocomplete="off" ></textarea>
|
||||||
|
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
|
||||||
|
<ng-container *ngFor="let validation of parent_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="parent_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field style="width: 100%" *ngIf="parent_ques.get('type').value == '8'">
|
||||||
|
<mat-label>{{parent_ques.get('question').value}}</mat-label>
|
||||||
|
<mat-select formControlName="answer_value" (selectionChange)="onChangeProperty($event,parent_ques,'','',p_i)">
|
||||||
|
<mat-option>
|
||||||
|
<ngx-mat-select-search formControlName="select_search"
|
||||||
|
[placeholderLabel]="'Search'"
|
||||||
|
[noEntriesFoundLabel]="'No Matching Result'" (keyup)="searchFun(parent_ques,p_i)">
|
||||||
|
<ion-icon name="md-close" ngxMatSelectSearchClear></ion-icon>
|
||||||
|
</ngx-mat-select-search>
|
||||||
|
</mat-option>
|
||||||
|
<mat-option>--</mat-option>
|
||||||
|
|
||||||
|
<mat-option *ngFor="let val of fileredSearchValue.length > 0 ? fileredSearchValue[p_i] : parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
|
||||||
|
<ng-container *ngFor="let validation of parent_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="parent_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="radio-gap" *ngIf="parent_ques.get('is_repeatable').value == '1' && parent_ques.controls['questions_group']">
|
||||||
|
<!-- <mat-card> -->
|
||||||
|
<!-- <mat-card-header>
|
||||||
|
<mat-card-title>
|
||||||
|
{{parent_ques.get('group_title').value}}
|
||||||
|
</mat-card-title>
|
||||||
|
</mat-card-header> -->
|
||||||
|
|
||||||
|
<div formArrayName="questions_group" *ngIf="parent_ques.get('group_type').value != '6'">
|
||||||
|
<span
|
||||||
|
*ngFor="let group_ques of parent_ques.controls.questions_group['controls'];let g_i=index;let g_l=last"
|
||||||
|
[formGroupName]="g_i">
|
||||||
|
<mat-accordion *ngIf="parent_ques.get('group_type').value != '6'" #accordion="matAccordion">
|
||||||
|
<mat-expansion-panel [expanded]="step === g_i" #mapanel="matExpansionPanel">
|
||||||
|
<mat-expansion-panel-header>
|
||||||
|
<mat-panel-title>
|
||||||
|
<span> {{parent_ques.get('group_title').value}}<span *ngIf="parent_ques.get('is_multi_disabled').value != '1'"> {{g_i+1}}</span></span>
|
||||||
|
</mat-panel-title>
|
||||||
|
<!-- <mat-panel-description>
|
||||||
|
Type your name and age
|
||||||
|
</mat-panel-description> -->
|
||||||
|
</mat-expansion-panel-header>
|
||||||
|
|
||||||
|
<div formArrayName="questions" *ngIf="group_ques.controls['questions']">
|
||||||
|
<div
|
||||||
|
*ngFor="let single_ques of group_ques.controls.questions['controls'];let s_i=index;let s_l=last"
|
||||||
|
[formGroupName]="s_i">
|
||||||
|
|
||||||
|
<mat-form-field style="width: 100%" *ngIf="single_ques.get('type').value == '1'" [ngStyle]="{'margin-bottom':single_ques.value.hasOwnProperty('field_type') ? single_ques.get('field_type').value == 'numtoword' ? '5%' : '0' : '' }">
|
||||||
|
<mat-label>{{single_ques.get('question').value}}</mat-label>
|
||||||
|
<input matInput [type]="single_ques.value.hasOwnProperty('field_type') ? single_ques.get('field_type').value == 'num' || single_ques.get('field_type').value == 'numtoword' ? 'number' : single_ques.get('field_type').value == 'string' ? 'text' : single_ques.get('field_type').value: ''" formControlName="answer_value"
|
||||||
|
[placeholder]="single_ques.value.hasOwnProperty('place_holder') ? single_ques.get('place_holder').value : ''"
|
||||||
|
autocomplete="off" (change)="onChangeProperty($event,single_ques,group_ques,2,s_i)">
|
||||||
|
<mat-hint *ngIf="single_ques.get('answer_value').value != '' && single_ques.value.hasOwnProperty('field_type') && single_ques.get('field_type').value == 'numtoword'" align="end" style="font-size: 10px;">{{"₹"}}{{single_ques.get('answer_value').value | numToWords}}</mat-hint>
|
||||||
|
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
|
||||||
|
<ng-container *ngFor="let validation of single_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="single_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<div class="radio-gap" *ngIf="single_ques.get('type').value == '2'">
|
||||||
|
<mat-label>{{single_ques.get('question').value}}</mat-label><br/>
|
||||||
|
<mat-radio-group aria-label="Select an option" formControlName="answer_value" (change)="onChangeProperty($event,single_ques,group_ques,2,s_i)">
|
||||||
|
<mat-radio-button class="radio-btn-gap" *ngFor="let val of single_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-radio-button><br />
|
||||||
|
</mat-radio-group>
|
||||||
|
<ng-container *ngFor="let validation of single_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="single_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<mat-form-field style="width: 100%" *ngIf="single_ques.get('type').value == '3'">
|
||||||
|
<mat-label>{{single_ques.get('question').value}}</mat-label>
|
||||||
|
<mat-select formControlName="answer_value" (selectionChange)="onChangeProperty($event,single_ques,group_ques,2,s_i)">
|
||||||
|
<mat-option *ngFor="let val of single_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
|
||||||
|
<ng-container *ngFor="let validation of single_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="single_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<div class="radio-gap" formArrayName="answer_value" *ngIf="single_ques.get('type').value == '5'">
|
||||||
|
<mat-label>{{single_ques.get('question').value}}</mat-label>
|
||||||
|
<mat-checkbox class="radio-btn-gap" *ngFor="let val of single_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer" (change)="onChange_checkbox($event,single_ques)">{{val.answer}}</mat-checkbox><br />
|
||||||
|
<ng-container *ngFor="let validation of single_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="single_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<mat-form-field style="width: 100%" *ngIf="single_ques.get('type').value == '4'">
|
||||||
|
<mat-label>{{single_ques.get('question').value}}</mat-label>
|
||||||
|
<mat-select multiple formControlName="answer_value">
|
||||||
|
<mat-option *ngFor="let val of single_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
|
||||||
|
<ng-container *ngFor="let validation of single_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="single_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field style="width: 100%" *ngIf="single_ques.get('type').value == '7'">
|
||||||
|
<mat-label>{{single_ques.get('question').value}}</mat-label>
|
||||||
|
<textarea matInput type="text" rows="3" formControlName="answer_value" placeholder="Enter the Text"
|
||||||
|
autocomplete="off" ></textarea>
|
||||||
|
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
|
||||||
|
<ng-container *ngFor="let validation of single_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="single_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field style="width: 100%" *ngIf="single_ques.get('type').value == '8'">
|
||||||
|
<mat-label>{{single_ques.get('question').value}}</mat-label>
|
||||||
|
<mat-select formControlName="answer_value" (selectionChange)="onChangeProperty($event,single_ques,p_i)">
|
||||||
|
<mat-option>
|
||||||
|
<ngx-mat-select-search formControlName="select_search"
|
||||||
|
[placeholderLabel]="'Search'"
|
||||||
|
[noEntriesFoundLabel]="'No Matching Result'" (keyup)="searchFun(single_ques,p_i)">
|
||||||
|
<ion-icon name="md-close" ngxMatSelectSearchClear (click) = "fileredSearchValue = []"></ion-icon>
|
||||||
|
</ngx-mat-select-search>
|
||||||
|
</mat-option>
|
||||||
|
<mat-option>--</mat-option>
|
||||||
|
|
||||||
|
<mat-option *ngFor="let val of fileredSearchValue.length > 0 ? fileredSearchValue[p_i] : single_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
|
||||||
|
<ng-container *ngFor="let validation of single_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="single_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<div *ngIf="single_ques.controls['subfield_key']">
|
||||||
|
<!-- <div *ngIf="parent_ques.controls[parent_ques.get('subfield_key').value]"> -->
|
||||||
|
<mat-form-field style="width: 100%" >
|
||||||
|
|
||||||
|
<mat-label>{{single_ques.get('subfield_caption').value}}</mat-label>
|
||||||
|
<input matInput type="text" formControlName="subfield_value" placeholder="Enter the Text"
|
||||||
|
autocomplete="off">
|
||||||
|
</mat-form-field>
|
||||||
|
<!-- </div> -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ion-buttons end *ngIf="parent_ques.get('is_multi_disabled').value != '1'">
|
||||||
|
<ion-col col-3 offset-3>
|
||||||
|
<button ion-button clear color="optblue" *ngIf="g_i != 0" (click)="removeData(g_i,parent_ques)">
|
||||||
|
<ion-icon style="font-size: 22px" name="md-trash"></ion-icon>
|
||||||
|
</button>
|
||||||
|
</ion-col>
|
||||||
|
<ion-col col-2 offset-1>
|
||||||
|
<button ion-button clear color="optblue" *ngIf="g_l"
|
||||||
|
(click)="addData(g_i,parent_ques,group_ques.get('questions').value,$event)">
|
||||||
|
<ion-icon style="font-size: 24px" name="add-circle"></ion-icon>
|
||||||
|
</button>
|
||||||
|
</ion-col>
|
||||||
|
</ion-buttons>
|
||||||
|
</mat-expansion-panel>
|
||||||
|
</mat-accordion>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div formArrayName="questions_group" *ngIf="parent_ques.get('group_type').value == '6'">
|
||||||
|
<hr class="hr">
|
||||||
|
<mat-card-header>
|
||||||
|
<mat-card-title>
|
||||||
|
<h5> {{parent_ques.get('group_title').value}}</h5>
|
||||||
|
</mat-card-title>
|
||||||
|
</mat-card-header>
|
||||||
|
|
||||||
|
<ion-grid >
|
||||||
|
<ion-row>
|
||||||
|
<span
|
||||||
|
*ngFor="let group_ques of parent_ques.controls.questions_group['controls'];let g_i=index;let g_l=last"
|
||||||
|
[formGroupName]="g_i">
|
||||||
|
<!-- </mat-card> -->
|
||||||
|
<span formArrayName="questions" *ngIf="group_ques.controls['questions'] && parent_ques.get('group_type').value == '6'" >
|
||||||
|
<!-- <div > -->
|
||||||
|
|
||||||
|
<!-- <div *ngIf="single_ques.get('type').value == '10'"> -->
|
||||||
|
|
||||||
|
<ion-col align-self: center col-6 no-padding text-center *ngFor="let single_ques of group_ques.controls.questions['controls'];let s_i=index;let s_l=last"
|
||||||
|
[formGroupName]="s_i">
|
||||||
|
<div style="width: 100%;justify-content: center;text-align: center;align-content: center;margin:2%;" *ngIf="single_ques.get('answer_value').value != ''">
|
||||||
|
<ion-row style="width: 100%">
|
||||||
|
<img [src]="single_ques.get('answer_value').value" imageViewer class="doc-image-bucket" ><br/>
|
||||||
|
</ion-row>
|
||||||
|
<ion-row style="width: 130px;margin-bottom: 5px;text-align: left">
|
||||||
|
<ion-col col-8>
|
||||||
|
<span style="font-size: 12px;padding: 0px;margin: 0px;">{{single_ques.get('question').value}} {{g_i+1}}</span>
|
||||||
|
</ion-col>
|
||||||
|
|
||||||
|
<!-- IMAGE STATUS ICON FOR INPROGRESS, COMPLETED AND FAILED -->
|
||||||
|
<ion-col col-4 *ngIf="single_ques.get('is_image_status').value == true">
|
||||||
|
<ion-spinner name="crescent" style="width: 20px;
|
||||||
|
height: 20px;" (click)="cancelLoader(single_ques)"
|
||||||
|
*ngIf="single_ques.get('is_loader').value == true"></ion-spinner>
|
||||||
|
<ion-icon style="color: #008828;float: right;
|
||||||
|
margin-right: 30%;" *ngIf="single_ques.get('is_saved').value == true" name="checkmark-circle-outline"></ion-icon>
|
||||||
|
<span style="margin:0px;" *ngIf="(single_ques.get('is_saved').value == false &&
|
||||||
|
single_ques.get('is_loader').value == false) && (single_ques.value.hasOwnProperty('is_saved') &&
|
||||||
|
single_ques.value.hasOwnProperty('is_loader'))" (click)="imageReupload(single_ques)">
|
||||||
|
<ion-row style="margin-top: -17px;padding:0px;"><button ion-button clear><ion-icon style="color:lightcoral;" name="refresh-circle"></ion-icon></button></ion-row>
|
||||||
|
<ion-row style="margin-top: -20px;padding:0px;"><p style="font-size: 10px">Click to ReUpload</p></ion-row>
|
||||||
|
</span>
|
||||||
|
</ion-col>
|
||||||
|
<!-- <input *ngIf="image.Name =='' && image.option != 'dummy'" width="20px" ion-input type="text" placeholder="Document Name" (blur)="changeName($event.target.value,i,image.image)"> -->
|
||||||
|
<!-- <button ion-button clear color="optblue" (click)="removeData(g_i,parent_ques)"><ion-icon style="font-size:22px" name="md-trash"></ion-icon></button> -->
|
||||||
|
</ion-row>
|
||||||
|
</div>
|
||||||
|
<!-- <div style="justify-content: center">
|
||||||
|
<button ion-button clear color="optblue" (click)="captureImg()"><ion-icon style="font-size: 30px" name="md-camera"></ion-icon></button>
|
||||||
|
</div> -->
|
||||||
|
<!-- {{single_ques.value | json}} -->
|
||||||
|
|
||||||
|
<div class="add-more-image" *ngIf="g_l">
|
||||||
|
<button ion-button clear style="color: black" [disabled]="sales_pd_type == '2'" (click)="addData(g_i,parent_ques,group_ques.get('questions').value,$event,'camera',single_ques)"><ion-icon style="font-size:35px" name="md-camera"></ion-icon>+</button>
|
||||||
|
</div>
|
||||||
|
</ion-col>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- </div> -->
|
||||||
|
|
||||||
|
<!-- </div> -->
|
||||||
|
</span>
|
||||||
|
<div *ngIf="g_l" style="justify-content: flex-end">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
</ion-row>
|
||||||
|
<!-- <ng-container *ngFor="let validation of single_ques.get('validations').value;" ngProjectAs="mat-error">
|
||||||
|
<mat-error align="end" *ngIf="single_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
|
||||||
|
</ng-container> -->
|
||||||
|
</ion-grid>
|
||||||
|
<hr class="hr">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div *ngIf="parent_ques.controls['subfield_key']">
|
||||||
|
<!-- <div *ngIf="parent_ques.controls[parent_ques.get('subfield_key').value]"> -->
|
||||||
|
<mat-form-field style="width: 100%" >
|
||||||
|
|
||||||
|
<mat-label>{{parent_ques.get('subfield_caption').value}}</mat-label>
|
||||||
|
<input matInput type="text" formControlName="subfield_value" placeholder="Enter the Text"
|
||||||
|
autocomplete="off">
|
||||||
|
</mat-form-field>
|
||||||
|
<!-- </div> -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ion-buttons end class="save-btn">
|
||||||
|
<!-- <ion-col *ngIf="!spinner_access">
|
||||||
|
<button class="btn-no-pad" medium ion-button round outline color="optblue" (click)="onSubmit(0)">Save as Draft</button>
|
||||||
|
</ion-col> -->
|
||||||
|
<ion-col *ngIf="!spinner_access">
|
||||||
|
<button class="btn-no-pad" medium ion-button type="submit" round color="optblue" (click)="onSubmit(1)"><ion-icon style="color:gray;font-size: 24px;" name="md-arrow-dropright-circle"></ion-icon> {{submit_btn ? 'Complete' : 'Save'}} </button>
|
||||||
|
</ion-col>
|
||||||
|
<ion-spinner name="dots" color="optblue" style="font-size: 24px;width:50px;height: 50px;" *ngIf="spinner_access"></ion-spinner>
|
||||||
|
</ion-buttons>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
48
src/pages/credit_pd/components/ques-template/ques-template.scss
Executable file
48
src/pages/credit_pd/components/ques-template/ques-template.scss
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
ques-template {
|
||||||
|
mat-radio-button,mat-checkbox{
|
||||||
|
margin-top: 13px;
|
||||||
|
}
|
||||||
|
.radio-gap{
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.radio-btn-gap{
|
||||||
|
margin:10px;
|
||||||
|
}
|
||||||
|
.doc-image-bucket{
|
||||||
|
padding:0 5px 0 0 !important;
|
||||||
|
width: 120px;
|
||||||
|
height: 80px !important;
|
||||||
|
color:black;
|
||||||
|
//width:130px;
|
||||||
|
//border:3px solid black;
|
||||||
|
//border-radius: 20px;
|
||||||
|
//background-color: gray;
|
||||||
|
}
|
||||||
|
.add-more-image{
|
||||||
|
width: 60%;
|
||||||
|
padding:0 5px 0 0 !important;
|
||||||
|
width: 120px;
|
||||||
|
height: 80px !important;
|
||||||
|
// border: 2px solid gainsboro;
|
||||||
|
// border-style: dashed;
|
||||||
|
// border-radius: 10px;
|
||||||
|
}
|
||||||
|
.hr, hr{
|
||||||
|
font-size: 25px;
|
||||||
|
}
|
||||||
|
// .btn-no-pad{
|
||||||
|
// padding: 8px 8px 8px 5px;
|
||||||
|
|
||||||
|
// }
|
||||||
|
.save-btn{
|
||||||
|
margin-top: 3%;
|
||||||
|
}
|
||||||
|
// .mat-input-invalid .mat-input-placeholder {
|
||||||
|
// color: red;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// .mat-input-invalid .mat-input-ripple {
|
||||||
|
// background-color: red;
|
||||||
|
// }
|
||||||
|
}
|
||||||
1580
src/pages/credit_pd/components/ques-template/ques-template.ts
Executable file
1580
src/pages/credit_pd/components/ques-template/ques-template.ts
Executable file
File diff suppressed because one or more lines are too long
97
src/pages/credit_pd/pages/credit-pd-list/credit-pd-list.html
Normal file
97
src/pages/credit_pd/pages/credit-pd-list/credit-pd-list.html
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
<!--
|
||||||
|
Generated template for the SalesPDlistPage page.
|
||||||
|
|
||||||
|
See http://ionicframework.com/docs/components/#navigation for more info on
|
||||||
|
Ionic pages and navigation.
|
||||||
|
-->
|
||||||
|
<ion-header>
|
||||||
|
|
||||||
|
<ion-navbar color="optblue">
|
||||||
|
<button ion-button menuToggle>
|
||||||
|
<ion-icon name="menu"></ion-icon>
|
||||||
|
</button>
|
||||||
|
<ion-title>Credit PD List</ion-title>
|
||||||
|
<ion-buttons end>
|
||||||
|
<button ion-button clear (click)="advancefilter()">
|
||||||
|
<ion-icon style="font-size: 23px;" ios="ios-options" md="md-options"></ion-icon>
|
||||||
|
</button>
|
||||||
|
</ion-buttons>
|
||||||
|
</ion-navbar>
|
||||||
|
</ion-header>
|
||||||
|
|
||||||
|
<ion-content padding>
|
||||||
|
<ion-refresher slot="fixed" (ionRefresh)="doRefresh($event)">
|
||||||
|
<ion-refresher-content></ion-refresher-content>
|
||||||
|
</ion-refresher>
|
||||||
|
<!-- <div class="pdf_source">
|
||||||
|
<pdf-viewer [src]="reportSrc"
|
||||||
|
[render-text]="true" [original-size]="false" [autoresize]="true"
|
||||||
|
style="display: block;"
|
||||||
|
></pdf-viewer>
|
||||||
|
</div> -->
|
||||||
|
<ion-list >
|
||||||
|
<ion-grid class="fadeIn">
|
||||||
|
<mat-card class="md-box" reorder="true">
|
||||||
|
<div *ngIf="loader_access">
|
||||||
|
<div *ngFor="let i of [1,2,3,4,5]">
|
||||||
|
<content-loader>
|
||||||
|
<svg:rect x="80" y="40" rx="5" ry="5" width="300" height="70" />
|
||||||
|
|
||||||
|
<svg:circle cx="40" cy="70" r="30" stroke="3" stroke-width="3" fill="red" />
|
||||||
|
|
||||||
|
</content-loader>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ion-list [virtualScroll]="sales_displayValue">
|
||||||
|
<ion-item *virtualItem="let val" (click)="val.status != 'COMPLETED' ? editForm(val) :presentActionSheet(val)" style="padding:0px"
|
||||||
|
[ngStyle]="{'border-left':(val.hasOwnProperty('is_pd_synced') && val.is_pd_synced == false) ||
|
||||||
|
(val.hasOwnProperty('is_all_section_synced') && val.is_all_section_synced == false) ||
|
||||||
|
(val.hasOwnProperty('is_pd_completed_sync') && val.hasOwnProperty('is_pd_completed') && val.is_pd_completed == true &&
|
||||||
|
val.is_pd_completed_sync == false)? '4px solid rgb(255, 184, 0)' : '4px solid #00ff009c'}">
|
||||||
|
<!-- <p item-start class="lettericon">{{val.abbr}}</p> -->
|
||||||
|
<!-- <ion-icon style="font-size:90%" item-start="" class="lettericon" [style.background]="bgColor[i]" *ngIf="progess.applicat_details ===undefined || progess.applicat_details[0].applicant_name ==null">{{progess.pd_id}}</ion-icon> -->
|
||||||
|
|
||||||
|
<ion-row>
|
||||||
|
<ion-col class="applicant_name" col-6 *ngIf="val.applicant_name != null">
|
||||||
|
<h1>{{val.applicant_name}}</h1>
|
||||||
|
<!--<p>28 Sep 2018 10:00 AM</p>-->
|
||||||
|
</ion-col>
|
||||||
|
<ion-col col-6 *ngIf="val.applicant_name == null">
|
||||||
|
<h1>Name Not Given</h1>
|
||||||
|
|
||||||
|
</ion-col>
|
||||||
|
<ion-col text-right>
|
||||||
|
<div style="font-size: 10px;color:black">
|
||||||
|
<p>{{val.createdon | date:'dd-MM-yy h:mm:ss a'}}</p>
|
||||||
|
<!-- <p>Chennai</p> -->
|
||||||
|
</div>
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
<ion-row>
|
||||||
|
<ion-col col-6>
|
||||||
|
<h6 class="app_id">{{val.smc_credit_pd_type == '1' ? 'Physical PD' : 'Telephonic PD'}}</h6>
|
||||||
|
</ion-col>
|
||||||
|
<ion-col text-right>
|
||||||
|
<div style="font-size: 13px;">
|
||||||
|
<h6><span style="font-size:13px">{{val.abbr}}</span> <span style="font-weight: bold">|</span> <span style="font-weight:bold;font-size:13px" [ngStyle]="{'color':val.status == 'COMPLETED' ? 'green' : 'orange'}">{{val.status}}</span></h6>
|
||||||
|
</div>
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
</ion-item>
|
||||||
|
|
||||||
|
|
||||||
|
</ion-list>
|
||||||
|
<div *ngIf="sales_displayValue.length == 0" style="padding: 10px; margin:5px;">
|
||||||
|
<h6 style="font-size: 20px">No Records Found</h6>
|
||||||
|
</div>
|
||||||
|
<p *ngIf="sales_displayValue.length > 0 && filterMsg" class="note">Showing data for last {{common}}. To see older records, please use <ion-icon name="options" style="color: black;font-size:15px;"></ion-icon> advanced filter</p>
|
||||||
|
</mat-card>
|
||||||
|
</ion-grid>
|
||||||
|
</ion-list>
|
||||||
|
<!-- <ion-fab right bottom (click)="newForm()" >
|
||||||
|
<button ion-fab mini color="optblue"><ion-icon color="light" name="md-add"></ion-icon></button>
|
||||||
|
</ion-fab> -->
|
||||||
|
<!-- <ion-footer>
|
||||||
|
|
||||||
|
</ion-footer> -->
|
||||||
|
</ion-content>
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { IonicPageModule } from 'ionic-angular';
|
||||||
|
import { CreditPdListPage } from './credit-pd-list';
|
||||||
|
import { ContentLoaderModule } from '@netbasal/content-loader';
|
||||||
|
import { MatCardModule } from '@angular/material';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
CreditPdListPage,
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
IonicPageModule.forChild(CreditPdListPage),
|
||||||
|
ContentLoaderModule,
|
||||||
|
MatCardModule
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class CreditPdListPageModule {}
|
||||||
139
src/pages/credit_pd/pages/credit-pd-list/credit-pd-list.scss
Normal file
139
src/pages/credit_pd/pages/credit-pd-list/credit-pd-list.scss
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
page-credit-pd-list {
|
||||||
|
mat-grid-tile {
|
||||||
|
background: white!important;
|
||||||
|
}
|
||||||
|
.grid{
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
.scroll-content{
|
||||||
|
padding: 0px !important;
|
||||||
|
// margin-top: 45px !important;
|
||||||
|
}
|
||||||
|
.fadeIn {
|
||||||
|
animation-name: fadeIn;
|
||||||
|
animation-duration: 15s;
|
||||||
|
transition: all 0.5s cubic-bezier(.36,-0.64,.34,1.76);
|
||||||
|
}
|
||||||
|
@font-face{
|
||||||
|
font-family: Roboto;
|
||||||
|
src: url('../../assets/fonts/Roboto-Bold.ttf')!important;
|
||||||
|
}
|
||||||
|
h1{
|
||||||
|
margin: 2px 0;
|
||||||
|
font-size: 2.1rem !important;
|
||||||
|
// overflow-wrap:break-word;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
// height: 10px;
|
||||||
|
// font-weight: bold!important;
|
||||||
|
}
|
||||||
|
// .box{
|
||||||
|
// box-shadow: 0 5px 20px 0 rgba(0,0,0,.2),0 13px 24px -11px rgba(50, 114, 178, 0.59) !important;
|
||||||
|
// }
|
||||||
|
.scroll-content{
|
||||||
|
//background-color: #eee !important;
|
||||||
|
padding:0px !important;
|
||||||
|
}
|
||||||
|
.mat-card{
|
||||||
|
// border-top: 3px solid rgba(50, 114, 178, 0.78);
|
||||||
|
padding: 0px !important;
|
||||||
|
box-shadow: none !important;
|
||||||
|
// margin-top: 10px;
|
||||||
|
// height: 100%;
|
||||||
|
}
|
||||||
|
*{
|
||||||
|
font-size: 10px;
|
||||||
|
// margin-top: 5px;
|
||||||
|
}
|
||||||
|
.mat-card-title{
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
||||||
|
.list-md{
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
// .lettericon{
|
||||||
|
// background-color: cadetblue;
|
||||||
|
// padding: 7px 8px 7px 8px;
|
||||||
|
// border-radius: 20%;
|
||||||
|
// color: #fff;
|
||||||
|
// font-size: 90%;
|
||||||
|
// font-weight:bold;
|
||||||
|
// text-align: center;
|
||||||
|
// }
|
||||||
|
.lettericon{
|
||||||
|
// padding: 7px 8px 7px 8px;
|
||||||
|
// border-radius: 20%;
|
||||||
|
color: red;
|
||||||
|
font-size: 90%;
|
||||||
|
font-weight:bold;
|
||||||
|
text-align: center;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
.app_id{
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
font-size: 12px;
|
||||||
|
// text-indent: 2%;
|
||||||
|
// letter-spacing: 1px;
|
||||||
|
// font-weight: bold;
|
||||||
|
}
|
||||||
|
.label-md{
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
.item-md h4 {
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
.item-md p{
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.item-md ion-icon[item-start] + .item-inner{
|
||||||
|
margin-left: 0px;
|
||||||
|
}
|
||||||
|
// ion-segment {
|
||||||
|
// justify-content: space-between;
|
||||||
|
// overflow: auto;
|
||||||
|
|
||||||
|
// &::-webkit-scrollbar {
|
||||||
|
// width: 0;
|
||||||
|
// height: 0;
|
||||||
|
// display: none;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// ion-segment-button.segment-button {
|
||||||
|
// flex: 1 0 100px;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
.applicant_name{
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
.action-sheet-md .action-sheet-group:first-child {
|
||||||
|
padding-top: 0.8rem;
|
||||||
|
border-radius: 15px 15px 0 0;
|
||||||
|
}
|
||||||
|
.action-sheet-container {
|
||||||
|
padding: 0 3% 0 3%;
|
||||||
|
font-weight:bold
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-sheet-md .action-sheet-button {
|
||||||
|
// font-weight: 500;
|
||||||
|
border-top:1px solid lightgray;
|
||||||
|
}
|
||||||
|
.action-sheet-md .action-sheet-icon {
|
||||||
|
margin: 0 10px 0 0;
|
||||||
|
}
|
||||||
|
p.note{
|
||||||
|
color: gray;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
float: center;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
371
src/pages/credit_pd/pages/credit-pd-list/credit-pd-list.ts
Normal file
371
src/pages/credit_pd/pages/credit-pd-list/credit-pd-list.ts
Normal file
@ -0,0 +1,371 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { IonicPage, NavController, NavParams, ActionSheetController, ModalController } from 'ionic-angular';
|
||||||
|
import { CreditSectionListPage } from '../credit-section-list/credit-section-list';
|
||||||
|
import { SalesPdProvider } from '../../../sales_pd/providers/sales-pd/sales-pd';
|
||||||
|
import { ToastProvider } from '../../../../providers/common-provider/toast';
|
||||||
|
import { LoadingProvider } from '../../../../providers/common-provider/loading';
|
||||||
|
import { IonicStorageProvider } from '../../../../providers/ionic-storage/ionic-storage';
|
||||||
|
import { CameraProvider } from '../../../sales_pd/providers/camera/camera';
|
||||||
|
import { ConstantsProvider } from '../../../../providers/constants/constants';
|
||||||
|
import { ReportViewer } from '../../../sales_pd/pages/report-pdf-viewer/pdf-modal';
|
||||||
|
import { OfflineManagerCreditProvider } from '../../providers/offline-manager-credit/offline-manager-credit';
|
||||||
|
import { ApiServiceProvider } from '../../providers/api-service/api-service';
|
||||||
|
import { forkJoin } from 'rxjs';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated class for the CreditPdListPage page.
|
||||||
|
*
|
||||||
|
* See https://ionicframework.com/docs/components/#navigation for more info on
|
||||||
|
* Ionic pages and navigation.
|
||||||
|
*/
|
||||||
|
const pd_key:any='local_credit_PDs'
|
||||||
|
@IonicPage()
|
||||||
|
@Component({
|
||||||
|
selector: 'page-credit-pd-list',
|
||||||
|
templateUrl: 'credit-pd-list.html',
|
||||||
|
})
|
||||||
|
export class CreditPdListPage {
|
||||||
|
sales_displayValue: any=[];
|
||||||
|
loader_access:any=true
|
||||||
|
reportSrc: any;
|
||||||
|
filter_drop_down_data: { product_ids: any[]; lender_ids: any[]; pd_status: any[]; };
|
||||||
|
filterMsg: boolean = false;
|
||||||
|
common: any;
|
||||||
|
localPDs:any =[ ]
|
||||||
|
is_sales_login:boolean = false
|
||||||
|
constructor(public actionSheetCtrl: ActionSheetController,public navCtrl: NavController, public navParams: NavParams,private salesPDService:ApiServiceProvider,private toastProvider:ToastProvider,private loaderProvider:LoadingProvider,private modalCtrl:ModalController,private offlineManager:OfflineManagerCreditProvider,
|
||||||
|
private ionicStorageService:IonicStorageProvider,private cameraProvider:CameraProvider,private constantProvider:ConstantsProvider,
|
||||||
|
private ionicStorageProvider:IonicStorageProvider) {
|
||||||
|
let userDetails = localStorage.getItem('user_details');
|
||||||
|
let role= this.constantProvider.takeDecisionRouting(JSON.parse(userDetails))
|
||||||
|
if(role == 'sales'){
|
||||||
|
this.is_sales_login = true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.is_sales_login = false
|
||||||
|
}
|
||||||
|
this.salesPDService.getEntityPreferences("35").subscribe(R=>{
|
||||||
|
// debugger;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
ionViewDidLoad() {
|
||||||
|
console.log('ionViewDidLoad SalesPDlistPage');
|
||||||
|
setTimeout(()=>{
|
||||||
|
this.common = JSON.parse(localStorage.getItem('commonSettings'))
|
||||||
|
if(this.common){
|
||||||
|
this.common = this.common.default_pd_list_count;
|
||||||
|
this.common = this.common.count+' '+this.common.factor
|
||||||
|
}
|
||||||
|
},300)
|
||||||
|
this.cameraProvider.checkGPSPermission();
|
||||||
|
// this.salesPDService.clearLocalData();
|
||||||
|
}
|
||||||
|
ionViewDidEnter(){
|
||||||
|
this.getListofPD()
|
||||||
|
}
|
||||||
|
doRefresh(event) {
|
||||||
|
console.log('refresh',event);
|
||||||
|
this.getListofPD();
|
||||||
|
setTimeout(() => {
|
||||||
|
// console.log('Async operation has ended');
|
||||||
|
event.complete();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
getListofLocalPD() {
|
||||||
|
return this.ionicStorageService.getLocalDataWithFilter(pd_key,{name:'local_pd_id',type:'filter',value :null}).then(result=>{
|
||||||
|
console.log(result,this.sales_displayValue)
|
||||||
|
if(result && result.length > 0){
|
||||||
|
let result_val = result
|
||||||
|
result_val.sort((a,b)=> 0 - (a>b ? -1 : 1));
|
||||||
|
this.localPDs = result_val
|
||||||
|
this.sales_displayValue.unshift(...this.localPDs);
|
||||||
|
}
|
||||||
|
this.loader_access=false
|
||||||
|
},err=>{
|
||||||
|
this.loader_access=false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
getListofPD(){
|
||||||
|
return this.ionicStorageService.getLocalDataWithFilter(pd_key,{name:'smc_credit_pd',type:'filter',value:null}).then(local_res=>{
|
||||||
|
console.log(local_res);
|
||||||
|
this.salesPDService.listSMCCreditPD().subscribe(res=>{
|
||||||
|
if(res['dataStatus']){
|
||||||
|
this.sales_displayValue=res['records']
|
||||||
|
if(local_res && local_res.length > 0) {
|
||||||
|
local_res.forEach(local_obj=>{
|
||||||
|
if(local_obj && local_obj.smc_credit_pd && local_obj.smc_credit_pd != null) {
|
||||||
|
console.log(local_obj)
|
||||||
|
let findListIndex = this.sales_displayValue.findIndex(val=>val.smc_credit_pd == local_obj.smc_credit_pd)
|
||||||
|
this.sales_displayValue[findListIndex].is_pd_synced = local_obj.is_pd_synced
|
||||||
|
this.sales_displayValue[findListIndex].is_all_section_synced = local_obj.is_all_section_synced
|
||||||
|
this.sales_displayValue[findListIndex].is_pd_completed = local_obj.is_pd_completed
|
||||||
|
this.sales_displayValue[findListIndex].is_pd_completed_sync = local_obj.is_pd_completed_sync
|
||||||
|
if(local_obj.hasOwnProperty('status') && local_obj.status){
|
||||||
|
this.sales_displayValue[findListIndex].status = local_obj.status
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.sales_displayValue.length > 0){
|
||||||
|
this.getSalesPDSectionData()
|
||||||
|
|
||||||
|
this.filterMsg = true
|
||||||
|
let products=[]
|
||||||
|
let lenders=[]
|
||||||
|
let pd_status=[]
|
||||||
|
this.sales_displayValue.map(val=>{
|
||||||
|
if(products.length > 0 ){
|
||||||
|
if(products.filter(pro=>pro == val.product_id).length == 0 ){
|
||||||
|
products.push(val.product_id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
products.push(val.product_id)
|
||||||
|
}
|
||||||
|
if(lenders.length > 0 ){
|
||||||
|
if(lenders.filter(pro=>pro == val.lender_id).length == 0 ){
|
||||||
|
lenders.push(val.lender_id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
lenders.push(val.lender_id)
|
||||||
|
}
|
||||||
|
if(pd_status.length > 0 ){
|
||||||
|
if(pd_status.filter(pro=>pro == val.status).length == 0 ){
|
||||||
|
pd_status.push(val.status)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
pd_status.push(val.status)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.filter_drop_down_data={product_ids:products,lender_ids:lenders,pd_status:pd_status}
|
||||||
|
console.log(this.sales_displayValue);
|
||||||
|
}
|
||||||
|
this.getListofLocalPD()
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.loader_access=false
|
||||||
|
}
|
||||||
|
|
||||||
|
},err=>{
|
||||||
|
console.log("Error",err)
|
||||||
|
this.loader_access=false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
getSalesPDSectionData() {
|
||||||
|
if(this.sales_displayValue.length > 0) {
|
||||||
|
let startedPD = this.sales_displayValue.filter(vv=>vv.status == 'STARTED')
|
||||||
|
if(startedPD && startedPD.length > 0) {
|
||||||
|
this.getAllStartedDatas(startedPD).subscribe(result=>{
|
||||||
|
console.log("at last",result)
|
||||||
|
// debugger;
|
||||||
|
this.ionicStorageProvider.inserDataWithReplace('getSalesPDSectionData',result)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getAllStartedDatas(startedPD) {
|
||||||
|
let allpdData:any = []
|
||||||
|
for(let item of startedPD) {
|
||||||
|
if(item) {
|
||||||
|
// let params={sales_pd_id:sales_pd_id,section_id:this.local_ques_JSON.section_id}
|
||||||
|
let params = {sales_pd_id:item.fk_sales_pd_id,section_id:'data'}
|
||||||
|
let temp:any= {}
|
||||||
|
temp = this.salesPDService.getSalesPDSectionData(params)
|
||||||
|
allpdData.push(temp)
|
||||||
|
// .subscribe(rr=>{
|
||||||
|
// allpdData.push(rr)
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return forkJoin(allpdData);
|
||||||
|
}
|
||||||
|
newForm(){
|
||||||
|
// this.salesPDService.getData_fromLocal('sec1').then(result=>{
|
||||||
|
// console.log("image",result);
|
||||||
|
// if(result){
|
||||||
|
// this.alertDecision()
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// this.navCtrl.push(HomePage)
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// this.salesPDService.clearLocalData()
|
||||||
|
// this.salesPDService.clear_local_key('sales_pd_id_PRIMARYKEY');
|
||||||
|
localStorage.removeItem('product_id_salesPD')
|
||||||
|
localStorage.removeItem('sales_pd_type')
|
||||||
|
// this.navCtrl.push(HomePage)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
editForm(value_obj){
|
||||||
|
// let product= localStorage.getItem('product_id_salesPD')
|
||||||
|
// storing the sales_pd_id and product id in local storagey
|
||||||
|
let primary_key= 'smc_credit_pd'
|
||||||
|
if(value_obj.hasOwnProperty('local_pd_id') && value_obj.local_pd_id != null && value_obj.sales_pd_id == null && value_obj.hasOwnProperty('is_pd_synced') && value_obj.is_pd_synced == false) {
|
||||||
|
primary_key = 'local_pd_id'
|
||||||
|
}
|
||||||
|
// this.salesPDService.insertData_Replace('sales_pd_id_PRIMARYKEY',value_obj[primary_key]).then(()=>{
|
||||||
|
// this.salesPDService.insertData_Replace('sales_rand_string',value_obj['rand_string']).then(()=>{
|
||||||
|
value_obj.smc_credit_pd = value_obj[primary_key]
|
||||||
|
this.salesPDService.curr_credit_pd_data = value_obj
|
||||||
|
localStorage.setItem('product_id_salesPD',value_obj.product_id)
|
||||||
|
if(!value_obj.hasOwnProperty('smc_credit_pd_type')&& !value_obj.smc_credit_pd_type) {
|
||||||
|
value_obj.smc_credit_pd_type = '1'
|
||||||
|
}
|
||||||
|
console.log(value_obj);
|
||||||
|
localStorage.setItem('sales_pd_type',value_obj.smc_credit_pd_type)
|
||||||
|
this.navCtrl.push(CreditSectionListPage,{product_id:value_obj.product_id,sales_pd_type:value_obj.smc_credit_pd_type})
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
// salesPDpdf(pdfdetail){
|
||||||
|
// this.loaderProvider.pdloader("Processing..")
|
||||||
|
// this.salesPDService.getSalesPdpdf(pdfdetail)
|
||||||
|
// .subscribe(
|
||||||
|
// data => {
|
||||||
|
// if (data.status == 200) {
|
||||||
|
// // window.open(data.records);
|
||||||
|
// // window.location.href=data.records;
|
||||||
|
// // window.open(data.records, '_blank');
|
||||||
|
// // this.reportSrc=data.records
|
||||||
|
// let profileModal = this.modalCtrl.create(ReportViewer,{'report_link':data.records});
|
||||||
|
// profileModal.present();
|
||||||
|
|
||||||
|
// }
|
||||||
|
// this.loaderProvider.dismissLoader();
|
||||||
|
// },err=>{
|
||||||
|
// this.loaderProvider.dismissLoader()
|
||||||
|
// console.log(err);
|
||||||
|
// let profileModal = this.modalCtrl.create(ReportViewer,{'error_msg':'Please check your internet connection to view PD reports. They are available only if you are connected.'});
|
||||||
|
// profileModal.present();
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// alertDecision(){
|
||||||
|
// let btns={button1:'New PD',button2:'Continue'}
|
||||||
|
// let alert = this.toastProvider.setAlertWithButtons("<small>You have one incomplete PD<small>", "<strong>Do you wish to continue the same or start with a new discussion<br/><small>Note:Starting New PD will delete the existing one.</small></strong>",btns)
|
||||||
|
// alert.present();
|
||||||
|
// alert.onDidDismiss((data) => {
|
||||||
|
// if (data == false) {
|
||||||
|
// this.salesPDService.clearLocalData()
|
||||||
|
// localStorage.removeItem('product_id_salesPD')
|
||||||
|
// localStorage.removeItem('sales_pd_type')
|
||||||
|
// this.navCtrl.push(HomePage)
|
||||||
|
// console.log(data)
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// let product= localStorage.getItem('product_id_salesPD')
|
||||||
|
// let sales_pd_type = localStorage.getItem('sales_pd_type')
|
||||||
|
// this.navCtrl.push(Section1,{product_id:product,sales_pd_type:sales_pd_type})
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
|
// }
|
||||||
|
// advancefilter(){
|
||||||
|
// const modalOption:ModalOptions={
|
||||||
|
// cssClass:'filterModal'
|
||||||
|
// }
|
||||||
|
// const modalCtrl=this.modalCtrl.create(AdvanceFilterPage,{'drop_down_datas':this.filter_drop_down_data},modalOption)
|
||||||
|
// modalCtrl.present();
|
||||||
|
// modalCtrl.onDidDismiss((data)=>{
|
||||||
|
// console.log(data)
|
||||||
|
// if(data){
|
||||||
|
// this.sales_displayValue = data;
|
||||||
|
// this.filterMsg = false
|
||||||
|
// }
|
||||||
|
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
presentActionSheet(value_obj) {
|
||||||
|
// if(this.is_sales_login) {
|
||||||
|
let actionSheet = this.actionSheetCtrl.create({
|
||||||
|
title: 'Select Option',
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
text: 'View Report',
|
||||||
|
icon:'eye',
|
||||||
|
role: 'destructive',
|
||||||
|
handler: () => {
|
||||||
|
// this.salesPDpdf(value_obj.sales_pd_id);
|
||||||
|
// console.log('pdf check',this.salesPDpdf);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Cancel',
|
||||||
|
role: 'cancel',
|
||||||
|
icon:'arrow-round-back',
|
||||||
|
handler: () => {
|
||||||
|
console.log('Cancel clicked');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
actionSheet.present();
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// let actionSheet = this.actionSheetCtrl.create({
|
||||||
|
// title: 'Select Option',
|
||||||
|
// buttons: [
|
||||||
|
// {
|
||||||
|
// text: 'Trigger Credit PD',
|
||||||
|
// icon:'add',
|
||||||
|
// role: 'credit',
|
||||||
|
// handler: () => {
|
||||||
|
// // this.salesPDpdf(value_obj.sales_pd_id);
|
||||||
|
// this.triggerCreditPdFun(value_obj)
|
||||||
|
// console.log('pdf check',this.salesPDpdf);
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// text: 'View Report',
|
||||||
|
// icon:'eye',
|
||||||
|
// role: 'destructive',
|
||||||
|
// handler: () => {
|
||||||
|
// this.salesPDpdf(value_obj.sales_pd_id);
|
||||||
|
// // console.log('pdf check',this.salesPDpdf);
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// text: 'Cancel',
|
||||||
|
// role: 'cancel',
|
||||||
|
// icon:'arrow-round-back',
|
||||||
|
// handler: () => {
|
||||||
|
// console.log('Cancel clicked');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// });
|
||||||
|
|
||||||
|
// actionSheet.present();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
// triggerCreditPdFun(curr_list_obj:any) {
|
||||||
|
// let message = 'Please Confirm you are triggering credit PD for the applicant <strong>'+curr_list_obj.applicant_name+'('+curr_list_obj.abbr+`)</strong><br/><br/>
|
||||||
|
// Choose the PD Type :`
|
||||||
|
// let pd_type_list:any=[{
|
||||||
|
// id:"1",
|
||||||
|
// dis_name:"Physical PD"
|
||||||
|
// },{
|
||||||
|
// id:"2",
|
||||||
|
// dis_name:"Telephonic PD"
|
||||||
|
// }]
|
||||||
|
// let alert = this.toastProvider.setAlertWithRadioButtons("Confirm",message,{button1:"Cancel",button2:'Yes'},pd_type_list)
|
||||||
|
// alert.present();
|
||||||
|
// alert.onDidDismiss((data)=>{
|
||||||
|
// console.log(data);
|
||||||
|
// if(data != false) {
|
||||||
|
// this.navCtrl.setRoot(CreditSectionListPage,{product_id:curr_list_obj.product_id,sales_pd_type:data})
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
39
src/pages/credit_pd/pages/credit-pd-ques/credit-pd-ques.html
Normal file
39
src/pages/credit_pd/pages/credit-pd-ques/credit-pd-ques.html
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<!--
|
||||||
|
Generated template for the CreditPdQuesPage page.
|
||||||
|
|
||||||
|
See http://ionicframework.com/docs/components/#navigation for more info on
|
||||||
|
Ionic pages and navigation.
|
||||||
|
-->
|
||||||
|
<ion-header style="background: #ff7f507d">
|
||||||
|
|
||||||
|
<ion-navbar color="optblue">
|
||||||
|
<button ion-button menuToggle>
|
||||||
|
<ion-icon name="menu"></ion-icon>
|
||||||
|
</button>
|
||||||
|
<ion-title>{{question_data.section_name}}</ion-title>
|
||||||
|
<!-- <ion-buttons end>
|
||||||
|
<button ion-button type="submit" color="primary">dd</button>
|
||||||
|
</ion-buttons> -->
|
||||||
|
</ion-navbar>
|
||||||
|
<!-- <div class="offline-class"> -->
|
||||||
|
<span *ngIf="network_status == 1"
|
||||||
|
style="width: 100%;
|
||||||
|
height: 34px;
|
||||||
|
text-align: center;">
|
||||||
|
<p style="margin: 3px">No Network Connection</p></span>
|
||||||
|
<!-- </div> -->
|
||||||
|
</ion-header>
|
||||||
|
|
||||||
|
|
||||||
|
<ion-content padding>
|
||||||
|
<mat-card>
|
||||||
|
<mat-card-content *ngIf="question_data.questions.length > 0">
|
||||||
|
|
||||||
|
<ques-template (emitter)="navigate($event)" [questions_JSON]="question_data" (imageUploadCheck)="setGroupControl($event)"></ques-template>
|
||||||
|
<!-- <button ion-button (click)="onChange()"></button> -->
|
||||||
|
</mat-card-content>
|
||||||
|
<mat-card-content *ngIf="question_data.questions.length == 0">
|
||||||
|
<h5>No Templates Found</h5>
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
</ion-content>
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { IonicPageModule } from 'ionic-angular';
|
||||||
|
import { CreditPdQuesPage } from './credit-pd-ques';
|
||||||
|
import { ComponentsModule } from '../../components/components.module';
|
||||||
|
import { MatCardModule } from '@angular/material';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
CreditPdQuesPage,
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
IonicPageModule.forChild(CreditPdQuesPage),
|
||||||
|
ComponentsModule,
|
||||||
|
MatCardModule
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class CreditPdQuesPageModule {}
|
||||||
25
src/pages/credit_pd/pages/credit-pd-ques/credit-pd-ques.scss
Normal file
25
src/pages/credit_pd/pages/credit-pd-ques/credit-pd-ques.scss
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
page-credit-pd-ques {
|
||||||
|
ion-content{
|
||||||
|
background: white!important;
|
||||||
|
background-color: white
|
||||||
|
}
|
||||||
|
// .mat-radio-label {
|
||||||
|
// cursor: pointer;
|
||||||
|
// display: inline-flex;
|
||||||
|
// align-items: center;
|
||||||
|
// white-space: pre-line;
|
||||||
|
// vertical-align: middle;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// .mat-radio-button{
|
||||||
|
// min-width: 35%;
|
||||||
|
// }
|
||||||
|
.offline-class{
|
||||||
|
background-color: rgba(255, 0, 0, 0.527);
|
||||||
|
p{
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
192
src/pages/credit_pd/pages/credit-pd-ques/credit-pd-ques.ts
Normal file
192
src/pages/credit_pd/pages/credit-pd-ques/credit-pd-ques.ts
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { IonicPage, NavController, NavParams } from 'ionic-angular';
|
||||||
|
import { ConnectionStatus, NetworkDetectionProvider } from '../../../../providers/network-detection/network-detection';
|
||||||
|
import { SalesPdProvider } from '../../../sales_pd/providers/sales-pd/sales-pd';
|
||||||
|
import { LoadingProvider } from '../../../../providers/common-provider/loading';
|
||||||
|
import { ToastProvider } from '../../../../providers/common-provider/toast';
|
||||||
|
import { CreditPdListPage } from '../credit-pd-list/credit-pd-list';
|
||||||
|
import { ApiServiceProvider } from '../../providers/api-service/api-service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated class for the CreditPdQuesPage page.
|
||||||
|
*
|
||||||
|
* See https://ionicframework.com/docs/components/#navigation for more info on
|
||||||
|
* Ionic pages and navigation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@IonicPage()
|
||||||
|
@Component({
|
||||||
|
selector: 'page-credit-pd-ques',
|
||||||
|
templateUrl: 'credit-pd-ques.html',
|
||||||
|
})
|
||||||
|
export class CreditPdQuesPage {
|
||||||
|
|
||||||
|
question_data: any;
|
||||||
|
raw_data:any;
|
||||||
|
section_local:number=9
|
||||||
|
all_sections:any;
|
||||||
|
formGroupValue: any=null;
|
||||||
|
network_status: ConnectionStatus
|
||||||
|
curr_pd_info: any;
|
||||||
|
|
||||||
|
constructor(public navCtrl: NavController, public navParams: NavParams,private SalesPDService:ApiServiceProvider,private loadingProvider:LoadingProvider,private toastProvider:ToastProvider
|
||||||
|
,private networkDetectionProvider:NetworkDetectionProvider) {
|
||||||
|
this.curr_pd_info = this.SalesPDService.curr_credit_pd_data
|
||||||
|
if(this.navParams.get('section_id')){
|
||||||
|
this.section_local=this.navParams.get('section_id')
|
||||||
|
}
|
||||||
|
// this.SalesPDService.getData().subscribe(result=>{
|
||||||
|
// this.raw_data=result['records']
|
||||||
|
// this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||||
|
// this.question_data=this.raw_data.sections.filter(val => val.section_id == this.section_local)[0]
|
||||||
|
// console.log(this.question_data)
|
||||||
|
// })
|
||||||
|
|
||||||
|
this.raw_data=this.SalesPDService.raw_credit_pd_template
|
||||||
|
this.raw_data = JSON.parse(JSON.stringify(this.raw_data));
|
||||||
|
// this.raw_data=JSON.parse(this.raw_data)
|
||||||
|
|
||||||
|
this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||||
|
console.log(this.all_sections)
|
||||||
|
this.question_data=this.raw_data.sections.filter(val => val.order_id == this.section_local)[0]
|
||||||
|
console.log(this.question_data)
|
||||||
|
|
||||||
|
// if(this.question_data.section_id == 9){
|
||||||
|
// this.sendDatatoApi()
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
ionViewDidLoad() {
|
||||||
|
console.log('ionViewDidLoad HomePage');
|
||||||
|
console.log("######Entered");
|
||||||
|
this.networkDetectionProvider.onNetworkChange().subscribe(result=>{
|
||||||
|
this.network_status = result
|
||||||
|
console.log(this.network_status);
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
ionViewCanLeave(){
|
||||||
|
if (this.question_data.section_id == 9) {
|
||||||
|
// this.SalesPDService.getData_fromLocal("sales_pd_id_PRIMARYKEY").then(curr_sales_pd_id => {
|
||||||
|
// this.SalesPDService.getData_fromLocal("sec9").then(sec_value => {
|
||||||
|
console.log("section 9 First")
|
||||||
|
if(this.formGroupValue) {
|
||||||
|
console.log("FormGroup",this.formGroupValue.questions.length);
|
||||||
|
if (this.formGroupValue != null) {
|
||||||
|
return this.checkImageUploadingStatus(this.formGroupValue).then(res=>{
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
|
||||||
|
}
|
||||||
|
console.log("Leaving on ionViewCanLeave");
|
||||||
|
}
|
||||||
|
setGroupControl(event){
|
||||||
|
this.formGroupValue=event
|
||||||
|
}
|
||||||
|
checkImageUploadingStatus(sec_value) {
|
||||||
|
console.log("Section 9",sec_value);
|
||||||
|
return new Promise((resolve,reject)=>{
|
||||||
|
let progress = this.checkTheUploadingProgress(sec_value);
|
||||||
|
|
||||||
|
if(progress == 1){
|
||||||
|
console.log("Section 9 Confirmed");
|
||||||
|
this.toastProvider.lenderappmessage("Some images are still uploading. Please wait...")
|
||||||
|
reject()
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
checkTheUploadingProgress(sec_value){
|
||||||
|
let form_structure=sec_value.questions
|
||||||
|
// form_structure.forEach(parent_ques=>{
|
||||||
|
for(let i=0; i<form_structure.length;i++){
|
||||||
|
let parent_ques = form_structure[i]
|
||||||
|
if(parent_ques.hasOwnProperty('is_repeatable') && parent_ques.is_repeatable != '1'){
|
||||||
|
if(parent_ques.is_loader == true){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
for(let p_i=0;p_i<parent_ques.questions_group.length;p_i++){
|
||||||
|
let group_ques = parent_ques.questions_group[p_i]
|
||||||
|
for(let g_i=0;g_i<group_ques.questions.length;g_i++){
|
||||||
|
let single_ques = group_ques.questions[g_i]
|
||||||
|
// parent_ques.questions_group.forEach(group_ques=>{
|
||||||
|
// group_ques.questions.forEach(single_ques=>{
|
||||||
|
if(single_ques.is_loader == true){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
stopDestroying(event){
|
||||||
|
console.log("stopDestroying",event)
|
||||||
|
}
|
||||||
|
// onChange(){
|
||||||
|
// this.navCtrl.push(HomePage)
|
||||||
|
// }
|
||||||
|
navigate(event){
|
||||||
|
|
||||||
|
console.log(event,this.all_sections[this.all_sections.length - 1]);
|
||||||
|
if(this.all_sections[this.all_sections.length - 1] != event.section_id){
|
||||||
|
this.navCtrl.pop()
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// this.sendData()
|
||||||
|
console.log("else part")
|
||||||
|
// this.sendDatatoApi()
|
||||||
|
// this.SalesPDService.clearLocalData()
|
||||||
|
// this.SalesPDService.clear_local_key('sales_pd_id_PRIMARYKEY');
|
||||||
|
let msg=event.hasOwnProperty('is_completed') && event.is_completed == true ? "Completed Successfully" : 'Saved Successfully..!'
|
||||||
|
this.toastProvider.lenderappmessage(msg);
|
||||||
|
// this.SalesPDService.clearLocalData()
|
||||||
|
// this.SalesPDService.clear_local_key('sales_pd_id_PRIMARYKEY');
|
||||||
|
localStorage.removeItem('product_id_salesPD')
|
||||||
|
setTimeout(()=>{
|
||||||
|
this.navCtrl.setRoot(CreditPdListPage)
|
||||||
|
},2000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// sendDatatoApi(){
|
||||||
|
// this.loadingProvider.pdloader('Please Wait...')
|
||||||
|
// this.SalesPDService.sendData(this.all_sections).then((res:any)=>{
|
||||||
|
// console.log(res)
|
||||||
|
// let params={pd_json:JSON.stringify(res)}
|
||||||
|
// this.SalesPDService.saveQuestions(params).subscribe(apiresult=>{
|
||||||
|
// if(apiresult['dataStatus']){
|
||||||
|
// this.SalesPDService.insertData_Replace('sales_pd_id_PRIMARYKEY',apiresult['records'])
|
||||||
|
// // this.SalesPDService.clearLocalData()
|
||||||
|
// // if(res.length > 1){
|
||||||
|
// // this.toastProvider.lenderappmessage("Saved Successfully..!");
|
||||||
|
// // }
|
||||||
|
// // setTimeout(()=>{
|
||||||
|
// // this.navCtrl.setRoot(SalesPDlistPage)
|
||||||
|
// // },2000)
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// this.toastProvider.lenderappmessage("Something went wrong");
|
||||||
|
// setTimeout(()=>{
|
||||||
|
// this.navCtrl.pop();
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// this.loadingProvider.dismissLoader();
|
||||||
|
// },err=>{
|
||||||
|
// this.loadingProvider.dismissLoader();
|
||||||
|
// console.log("error",err);
|
||||||
|
// this.toastProvider.lenderappmessage('Network Error')
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
<!--
|
||||||
|
Generated template for the SectionListPage page.
|
||||||
|
|
||||||
|
See http://ionicframework.com/docs/components/#navigation for more info on
|
||||||
|
Ionic pages and navigation.
|
||||||
|
-->
|
||||||
|
<ion-header>
|
||||||
|
|
||||||
|
<ion-navbar color="optblue">
|
||||||
|
<button ion-button menuToggle>
|
||||||
|
<ion-icon name="menu"></ion-icon>
|
||||||
|
</button>
|
||||||
|
<ion-title>Credit PD Section List</ion-title>
|
||||||
|
|
||||||
|
<ion-buttons end *ngIf="is_sync_btn">
|
||||||
|
<button ion-button outline round (click)="syncPDWithSections()"><ion-icon name="sync"></ion-icon> Sync</button>
|
||||||
|
</ion-buttons>
|
||||||
|
</ion-navbar>
|
||||||
|
</ion-header>
|
||||||
|
|
||||||
|
|
||||||
|
<ion-content padding>
|
||||||
|
<!-- {{pd_completed | json}} -->
|
||||||
|
<!-- <div class="completed_note" *ngIf ="!is_sync_btn && pd_completed.is_synced == false && pd_completed.is_completed &&
|
||||||
|
pd_completed.pd_complete_request_items != null">
|
||||||
|
<p >PD Completion is not synced yet.
|
||||||
|
<button small ion-button outline round (click)="syncPDWithSections()"><ion-icon name="sync"></ion-icon> Sync</button>
|
||||||
|
</p>
|
||||||
|
</div> -->
|
||||||
|
<div class="completed_note" *ngIf ="is_sync_btn && pd_completed.is_synced == false && pd_completed.is_completed &&
|
||||||
|
pd_completed.pd_complete_request_items != null">
|
||||||
|
<p >
|
||||||
|
PD is completed. Please click the sync button above to send the data to server when internet is available.</p>
|
||||||
|
</div>
|
||||||
|
<!-- <div class="completed_note" *ngIf ="is_sync_btn && !pd_completed.is_completed">
|
||||||
|
<p >
|
||||||
|
PD section saved. Click sync to complete</p>
|
||||||
|
</div> -->
|
||||||
|
<mat-card class="card-class"
|
||||||
|
[ngClass]="{'border-disabled': sales_pd_id == null && sec.is_disabled,
|
||||||
|
'border-saved-local': sales_pd_id != null && sec.hasOwnProperty('status') &&
|
||||||
|
sec.status == '1' && sec.hasOwnProperty('is_synced') && sec.is_synced == false,
|
||||||
|
'border-saved': sales_pd_id != null && sec.hasOwnProperty('status') &&
|
||||||
|
sec.status == '1'
|
||||||
|
}" *ngFor="let sec of section_template" (click)="goto(sec.order_id)">
|
||||||
|
<ion-row>
|
||||||
|
<ion-col col-11>
|
||||||
|
<h6>{{sec.section_name}}</h6>
|
||||||
|
</ion-col>
|
||||||
|
<ion-col col-1 *ngIf="sec.hasOwnProperty('status') && sec.status == '1'">
|
||||||
|
<ion-icon name="checkmark-circle-outline"></ion-icon>
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
|
<ion-fab bottom right #fab color="optblue" *ngIf="customer_link != '' && sales_pd_type == '2'">
|
||||||
|
<button clear ion-fab mini color="mickyColor"><ion-icon name="link"></ion-icon></button>
|
||||||
|
<ion-fab-list side="top">
|
||||||
|
<button color="mickyColor" ion-fab (click)="copyToClipBoard(customer_link_with_text, 'Customer Link is copied');fab.close();"><ion-icon name="copy"></ion-icon>
|
||||||
|
<ion-label>Copy Link</ion-label>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button color="mickyColor" ion-fab (click)="shareViaSMS();fab.close();" ><ion-icon name="mail"></ion-icon>
|
||||||
|
<ion-label >Send Link via SMS</ion-label>
|
||||||
|
</button>
|
||||||
|
</ion-fab-list>
|
||||||
|
</ion-fab>
|
||||||
|
</ion-content>
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { IonicPageModule } from 'ionic-angular';
|
||||||
|
import { CreditSectionListPage } from './credit-section-list';
|
||||||
|
import { MatCardModule } from '@angular/material';
|
||||||
|
import { CreditPdQuesPageModule } from '../credit-pd-ques/credit-pd-ques.module';
|
||||||
|
import { CreditPdListPageModule } from '../credit-pd-list/credit-pd-list.module';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
CreditSectionListPage,
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
IonicPageModule.forChild(CreditSectionListPage),
|
||||||
|
MatCardModule,
|
||||||
|
CreditPdQuesPageModule,
|
||||||
|
CreditPdListPageModule,
|
||||||
|
|
||||||
|
],
|
||||||
|
entryComponents:[CreditSectionListPage]
|
||||||
|
})
|
||||||
|
export class CreditSectionListPageModule {}
|
||||||
@ -0,0 +1,99 @@
|
|||||||
|
page-credit-section-list {
|
||||||
|
ion-content {
|
||||||
|
contain: size style;
|
||||||
|
}
|
||||||
|
.card-class{
|
||||||
|
h6{
|
||||||
|
margin: 0px !important;
|
||||||
|
color: darkblue;
|
||||||
|
}
|
||||||
|
padding: 10px 9px;
|
||||||
|
margin: 0px;
|
||||||
|
margin-bottom: 14px;
|
||||||
|
border-radius: 5px !important;
|
||||||
|
/* font-size: 12px; */
|
||||||
|
// box-shadow: 0px;
|
||||||
|
box-shadow: 0 4px 4px -10px rgba(0, 0, 0, 0.56), 0 5px 16px 0 rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.2) !important;
|
||||||
|
border-left: 2px solid blue !important;
|
||||||
|
border:1px solid lavender;
|
||||||
|
// border: 1px solid #32db64;
|
||||||
|
// 2px solid #e1383863
|
||||||
|
// 2px solid #32db6475
|
||||||
|
// border-left: 1px sold red !important;
|
||||||
|
ion-icon{
|
||||||
|
color: #008828
|
||||||
|
}
|
||||||
|
transition: padding 2s;
|
||||||
|
}
|
||||||
|
.card-class:active {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.border-disabled{
|
||||||
|
border-left: 2px solid #00000075 !important;
|
||||||
|
h6{
|
||||||
|
margin: 0px !important;
|
||||||
|
color: darkgray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.border-saved{
|
||||||
|
border-left: 2px solid #008828 !important;
|
||||||
|
h6{
|
||||||
|
margin: 0px !important;
|
||||||
|
color:#00611d;
|
||||||
|
}
|
||||||
|
// #009b2e
|
||||||
|
}
|
||||||
|
.border-saved-local{
|
||||||
|
border-left: 2px solid rgb(255, 167, 5) !important;
|
||||||
|
h6{
|
||||||
|
margin: 0px !important;
|
||||||
|
color:#bc7a00;
|
||||||
|
}
|
||||||
|
// #009b2e
|
||||||
|
}
|
||||||
|
.completed_note.ng-star-inserted {
|
||||||
|
padding: 2px;
|
||||||
|
/* font-size: 2px; */
|
||||||
|
color: #2b7ecf;
|
||||||
|
/* border: 1px solid lightgray; */
|
||||||
|
p , a {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
padding: 0px;
|
||||||
|
margin:0px;
|
||||||
|
margin-bottom: 3px;
|
||||||
|
}
|
||||||
|
button {
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
button[ion-fab] {
|
||||||
|
overflow: visible;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
ion-label {
|
||||||
|
position: absolute;
|
||||||
|
top: -8px;
|
||||||
|
right: 40px;
|
||||||
|
|
||||||
|
color: white;
|
||||||
|
background-color: rgba(0,0,0,0.7);
|
||||||
|
line-height: 24px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.fab{
|
||||||
|
contain: layout;
|
||||||
|
// top:-40px;
|
||||||
|
}
|
||||||
|
// .fab[mini] {
|
||||||
|
// margin: 8px;
|
||||||
|
// width: 40px;
|
||||||
|
// height: 40px;
|
||||||
|
// line-height: 40px;
|
||||||
|
// }
|
||||||
|
}
|
||||||
@ -0,0 +1,247 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { IonicPage, NavController, NavParams } from 'ionic-angular';
|
||||||
|
import { SalesPdProvider } from '../../../sales_pd/providers/sales-pd/sales-pd';
|
||||||
|
import { ConstantsProvider } from '../../../../providers/constants/constants';
|
||||||
|
import { SocialSharing } from '@ionic-native/social-sharing';
|
||||||
|
import { ToastProvider } from '../../../../providers/common-provider/toast';
|
||||||
|
import { CreditPdQuesPage } from '../credit-pd-ques/credit-pd-ques';
|
||||||
|
import { CreditPdQuesPageModule } from '../credit-pd-ques/credit-pd-ques.module';
|
||||||
|
import { OfflineManagerCreditProvider } from '../../providers/offline-manager-credit/offline-manager-credit';
|
||||||
|
import { ApiServiceProvider } from '../../providers/api-service/api-service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated class for the CreditSectionListPage page.
|
||||||
|
*
|
||||||
|
* See https://ionicframework.com/docs/components/#navigation for more info on
|
||||||
|
* Ionic pages and navigation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@IonicPage()
|
||||||
|
@Component({
|
||||||
|
selector: 'page-credit-section-list',
|
||||||
|
templateUrl: 'credit-section-list.html',
|
||||||
|
})
|
||||||
|
export class CreditSectionListPage {
|
||||||
|
|
||||||
|
section_template: any=[];
|
||||||
|
raw_data: any;
|
||||||
|
all_sections: any;
|
||||||
|
product_id:string
|
||||||
|
sales_pd_id: any;
|
||||||
|
is_sync_btn: boolean = false;
|
||||||
|
pd_completed: any = {};
|
||||||
|
customer_link:string=''
|
||||||
|
sales_pd_type: string;
|
||||||
|
customer_link_with_text: string;
|
||||||
|
curr_pd_info: any;
|
||||||
|
constructor(public navCtrl: NavController, public navParams: NavParams,private toastProvider:ToastProvider,
|
||||||
|
private offlineManager:OfflineManagerCreditProvider,private constantProvider:ConstantsProvider,
|
||||||
|
private socialSharing:SocialSharing,private apiService:ApiServiceProvider) {
|
||||||
|
this.curr_pd_info = this.apiService.curr_credit_pd_data
|
||||||
|
|
||||||
|
if(this.navParams.get('product_id')){
|
||||||
|
this.product_id=this.navParams.get('product_id')
|
||||||
|
}
|
||||||
|
if(this.navParams.get('sales_pd_type')) {
|
||||||
|
this.sales_pd_type = this.navParams.get('sales_pd_type')
|
||||||
|
localStorage.setItem('sales_pd_type',this.sales_pd_type)
|
||||||
|
}
|
||||||
|
// this.sales_pd_type = localStorage.getItem('sales_pd_type')
|
||||||
|
this.getTemplate()
|
||||||
|
}
|
||||||
|
|
||||||
|
ionViewDidLoad() {
|
||||||
|
console.log('ionViewDidLoad SectionListPage');
|
||||||
|
// this.getSectionData()
|
||||||
|
|
||||||
|
}
|
||||||
|
ionViewDidEnter(){
|
||||||
|
setTimeout(()=>{
|
||||||
|
this.getSectionStats()
|
||||||
|
},50)
|
||||||
|
}
|
||||||
|
getSectionStats() {
|
||||||
|
// this.SalesPDService.getData_fromLocal('sales_pd_id_PRIMARYKEY').then((key_value)=>{
|
||||||
|
let key_value = this.curr_pd_info.smc_credit_pd
|
||||||
|
if(key_value && key_value != null && key_value != '' && key_value != undefined){
|
||||||
|
this.sales_pd_id=key_value
|
||||||
|
if(!this.sales_pd_id.includes('local')) {
|
||||||
|
let rand_string_sales = this.curr_pd_info.rand_string
|
||||||
|
// this.SalesPDService.getData_fromLocal('sales_rand_string').then((rand_string_sales)=>{
|
||||||
|
if(rand_string_sales) {
|
||||||
|
this.customer_link = this.constantProvider.environment().app_origin+'/customer/#/salespd-images/'+rand_string_sales;
|
||||||
|
this.customer_link_with_text = 'Dear applicant, please click the link to upload the photographs. '+this.customer_link
|
||||||
|
}
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
let params={smc_credit_pd:this.sales_pd_id,section_id:'all'}
|
||||||
|
this.apiService.getSMCCreditPDSectionData(params).subscribe(res=>{
|
||||||
|
// console.log(this.section_template,res);
|
||||||
|
if(this.section_template.length > 0)
|
||||||
|
{
|
||||||
|
console.log("if part")
|
||||||
|
this.merge_saved_status(res);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
setTimeout(()=>{
|
||||||
|
console.log("Else part",this.section_template.length)
|
||||||
|
if(this.section_template.length > 0)
|
||||||
|
{
|
||||||
|
this.merge_saved_status(res);
|
||||||
|
}
|
||||||
|
},500)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.sales_pd_id=null
|
||||||
|
}
|
||||||
|
let keyToCheck = 'sales_pd_id'
|
||||||
|
let params:any ={}
|
||||||
|
if(typeof(key_value) == 'string' && key_value.includes('local')) {
|
||||||
|
params.local_pd_id = key_value
|
||||||
|
keyToCheck = 'local_pd_id'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
params.sales_pd_id = key_value
|
||||||
|
}
|
||||||
|
console.log("#$$$$$",params)
|
||||||
|
if(params[keyToCheck] != null) {
|
||||||
|
return this.offlineManager.checkTheExistingPDLocally(params[keyToCheck],keyToCheck).then(result=>{
|
||||||
|
if(result) {
|
||||||
|
this.pd_completed.is_synced= result.is_pd_completed_sync
|
||||||
|
this.pd_completed.is_completed = result.is_pd_completed
|
||||||
|
// console.clear();
|
||||||
|
console.log("#$$4",result.pd_complete_request_items)
|
||||||
|
this.pd_completed.pd_complete_request_items = result.pd_complete_request_items ? result.pd_complete_request_items : null
|
||||||
|
// console.log(this.pd_completed.pd_complete_request_items, ((this.pd_completed.is_synced == false) || (this.pd_completed.is_completed == false && this.pd_completed.pd_complete_request_items != null && this.pd_completed.pd_complete_request_items != undefined)));
|
||||||
|
if((this.pd_completed.is_synced == false) && (this.pd_completed.is_completed == false && this.pd_completed.pd_complete_request_items != null && this.pd_completed.pd_complete_request_items != undefined)) {
|
||||||
|
console.log("Sync btn true")
|
||||||
|
this.is_sync_btn = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
merge_saved_status(res){
|
||||||
|
let saved_sections=res['records'].map(val=>{return {'section_id':val.section_id , 'status':val.status,'is_synced':val.is_synced}});
|
||||||
|
console.log("saved",saved_sections);
|
||||||
|
if(saved_sections) {
|
||||||
|
this.curr_pd_info.saved_sections = saved_sections
|
||||||
|
}
|
||||||
|
const mergeById = (a1, a2) =>
|
||||||
|
a1.map(itm => ({
|
||||||
|
...a2.find((item) => (item.section_id === itm.section_id) && item),
|
||||||
|
...itm
|
||||||
|
}));
|
||||||
|
this.section_template = mergeById(this.section_template,saved_sections);
|
||||||
|
console.log("##########",this.section_template);
|
||||||
|
if(this.section_template.length > 0) {
|
||||||
|
this.is_sync_btn = this.section_template.filter(val=>val.is_synced == false && val.section_id != 'all').length > 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getTemplate(){
|
||||||
|
this.apiService.loadTemplate().subscribe(result=>{
|
||||||
|
console.log(result);
|
||||||
|
// debugger;
|
||||||
|
// return
|
||||||
|
// })
|
||||||
|
// this.SalesPDService.getData(this.product_id,this.sales_pd_type).subscribe(result=>{
|
||||||
|
console.log("result",result)
|
||||||
|
// debugger;
|
||||||
|
if(result['dataStatus'] && result.hasOwnProperty('records')){
|
||||||
|
|
||||||
|
this.raw_data=JSON.parse(result['records'].template)
|
||||||
|
this.raw_data.sections.forEach((val,index)=>{
|
||||||
|
val.order_id=index+1
|
||||||
|
})
|
||||||
|
console.log(this.raw_data)
|
||||||
|
// this.SalesPDService.getData_fromLocal('sales_pd_id_PRIMARYKEY').then((key_value)=>{
|
||||||
|
let key_value = this.curr_pd_info.smc_credit_pd
|
||||||
|
console.log("sales pd id",key_value)
|
||||||
|
if(key_value && key_value != null && key_value != '' && key_value != undefined){
|
||||||
|
this.sales_pd_id=key_value
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.sales_pd_id=null
|
||||||
|
}
|
||||||
|
this.section_template=this.raw_data.sections.map(val=> {
|
||||||
|
let temp={section_id:val.section_id,section_name:val.section_name,order_id:val.order_id,is_disabled:val.section_id != '1' ? this.sales_pd_id == null ? true : false : false}
|
||||||
|
return temp
|
||||||
|
})
|
||||||
|
console.log(this.section_template)
|
||||||
|
// })
|
||||||
|
|
||||||
|
this.apiService.raw_credit_pd_template=this.raw_data
|
||||||
|
// localStorage.setItem('question_temp_salespd',JSON.stringify(this.raw_data))
|
||||||
|
// console.log("sales pd",this.SalesPDService.original_rawData)
|
||||||
|
this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||||
|
this.apiService.available_sections=this.all_sections
|
||||||
|
this.apiService.current_section='1';
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
let message = result['msg'] ? result['msg'] : 'Something went wrong'
|
||||||
|
let alert = this.toastProvider.setAlertWithOkButton("Alert",message);
|
||||||
|
alert.present();
|
||||||
|
this.navCtrl.pop();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
goto(section_id){
|
||||||
|
// this.SalesPDService.insertData_Replace('sales_pd_id_PRIMARYKEY',value_obj.sales_pd_id).then(()=>{
|
||||||
|
// localStorage.setItem('product_id_salesPD',value_obj.product_id)
|
||||||
|
if(this.sales_pd_id == null && section_id != '1'){
|
||||||
|
this.toastProvider.lenderappmessage("Please Fill General Section First !!")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setTimeout(()=>{
|
||||||
|
this.navCtrl.push(CreditPdQuesPage,{section_id:section_id})
|
||||||
|
},10)
|
||||||
|
}
|
||||||
|
syncPDWithSections() {
|
||||||
|
this.offlineManager.checkAndSyncPDWithSection(this.sales_pd_id).then(result=>{
|
||||||
|
console.log(result['dataStatus'])
|
||||||
|
if(result['dataStatus']) {
|
||||||
|
this.toastProvider.lenderappmessage("Synced Successfully")
|
||||||
|
setTimeout(()=>{
|
||||||
|
this.navCtrl.pop()
|
||||||
|
},3000)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.toastProvider.lenderappmessage(result['msg'])
|
||||||
|
setTimeout(()=>{
|
||||||
|
this.navCtrl.pop()
|
||||||
|
},3000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
copyToClipBoard(message,user_msg?) {
|
||||||
|
const selBox = document.createElement('textarea');
|
||||||
|
selBox.style.position = 'fixed';
|
||||||
|
selBox.style.left = '0';
|
||||||
|
selBox.style.top = '0';
|
||||||
|
selBox.style.opacity = '0';
|
||||||
|
selBox.value = message;
|
||||||
|
document.body.appendChild(selBox);
|
||||||
|
selBox.focus();
|
||||||
|
selBox.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
document.body.removeChild(selBox);
|
||||||
|
if(message == '') {
|
||||||
|
user_msg = "Something went wrong"
|
||||||
|
}
|
||||||
|
this.toastProvider.lenderappmessage(user_msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
shareViaSMS() {
|
||||||
|
this.socialSharing.shareViaSMS(this.customer_link_with_text,'').then(result=>{
|
||||||
|
console.log(result)
|
||||||
|
},err=>{
|
||||||
|
console.log(err);
|
||||||
|
alert("SMS Error "+JSON.stringify(err));
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
688
src/pages/credit_pd/providers/api-service/api-service.ts
Normal file
688
src/pages/credit_pd/providers/api-service/api-service.ts
Normal file
@ -0,0 +1,688 @@
|
|||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable, Observer } from 'rxjs';
|
||||||
|
import { ConstantsProvider } from '../../../../providers/constants/constants';
|
||||||
|
import { Storage } from '@ionic/storage';
|
||||||
|
import { NetworkDetectionProvider, ConnectionStatus } from '../../../../providers/network-detection/network-detection';
|
||||||
|
import { IonicStorageProvider } from '../../../../providers/ionic-storage/ionic-storage';
|
||||||
|
import { OfflineManagerCreditProvider } from '../offline-manager-credit/offline-manager-credit';
|
||||||
|
|
||||||
|
/*
|
||||||
|
Generated class for the ApiServiceProvider provider.
|
||||||
|
|
||||||
|
See https://angular.io/guide/dependency-injection for more info on providers
|
||||||
|
and Angular DI.
|
||||||
|
*/
|
||||||
|
const pd_key ='local_credit_PDs'
|
||||||
|
@Injectable()
|
||||||
|
export class ApiServiceProvider {
|
||||||
|
public curr_credit_pd_data:any = {}
|
||||||
|
public raw_credit_pd_template:any;
|
||||||
|
public user_login_details:any ={}
|
||||||
|
public available_sections:any;
|
||||||
|
public current_section:string
|
||||||
|
apiUrl: string;
|
||||||
|
constructor(public http: HttpClient,private constantProvider:ConstantsProvider,private storage:Storage,
|
||||||
|
private networkProvider:NetworkDetectionProvider,private ionicStorageProvider:IonicStorageProvider,
|
||||||
|
private offlineManagerProvider:OfflineManagerCreditProvider) {
|
||||||
|
console.log('Hello ApiServiceProvider Provider');
|
||||||
|
this.apiUrl = this.constantProvider.environment().url
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
loadTemplate() {
|
||||||
|
let params = {dummy_template:true}
|
||||||
|
return Observable.create((observer:any)=>{
|
||||||
|
console.log(this.networkProvider.getCurrentNetworkStatus());
|
||||||
|
|
||||||
|
|
||||||
|
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||||
|
console.log("sdaf")
|
||||||
|
|
||||||
|
this.http.get('assets/credit_pd_template.json').subscribe(rr=>{
|
||||||
|
const res = {dataStatus:true,status:200,records:{template:JSON.stringify(rr)}}
|
||||||
|
console.log(res)
|
||||||
|
// debugger;
|
||||||
|
if(res['dataStatus'] && res.hasOwnProperty('records') && res.records.hasOwnProperty('template')){
|
||||||
|
this.raw_credit_pd_template = res.records.template
|
||||||
|
let store_res= JSON.parse(JSON.stringify(res))
|
||||||
|
return this.ionicStorageProvider.checkAndInsertApiDataLocally(store_res,params,'credit_pd_template',true).then(res=>{
|
||||||
|
observer.next({dataStatus:true,status:200,records:{template:JSON.stringify(rr)}})
|
||||||
|
observer.complete();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
observer.next({dataStatus:true,status:200,records:{template:JSON.stringify(rr)}})
|
||||||
|
observer.complete();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this.ionicStorageProvider.getApiDataFromLocally(params,'credit_pd_template').subscribe(result=>{
|
||||||
|
observer.next(result)
|
||||||
|
observer.complete();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
getCityPincode(value){
|
||||||
|
let params={records:{state_id:value}}
|
||||||
|
return Observable.create((observer:any)=>{
|
||||||
|
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||||
|
return this.http.post(this.apiUrl+"getListOfStatesAndCities",params).subscribe(result=>{
|
||||||
|
return this.ionicStorageProvider.checkAndInsertApiDataLocally(result,params,'getListOfStatesAndCities',true).then(res=>{
|
||||||
|
observer.next(result);
|
||||||
|
observer.complete();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this.ionicStorageProvider.getApiDataFromLocally(params,'getListOfStatesAndCities').subscribe(result=>{
|
||||||
|
observer.next(result);
|
||||||
|
observer.complete();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
api_post_method(api_name:string,params,api_method?){
|
||||||
|
|
||||||
|
if(api_method.toUpperCase() == 'POST'){
|
||||||
|
return this.http.post(this.apiUrl+api_name,params)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return this.http.get(this.apiUrl+api_name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getSalesPDSectionData(params) {
|
||||||
|
return Observable.create((observer:any)=>{
|
||||||
|
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||||
|
return this.http.post(this.apiUrl+'getSalesPDSectionData',{records:params}).subscribe(rr=>{
|
||||||
|
let temp:any =rr
|
||||||
|
temp.params = params
|
||||||
|
|
||||||
|
observer.next(temp);
|
||||||
|
observer.complete();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else if(params.section_id != 'data'){
|
||||||
|
// debugger;
|
||||||
|
let temp = JSON.parse(JSON.stringify(params))
|
||||||
|
temp.section_id = "data"
|
||||||
|
console.log(temp)
|
||||||
|
// debugger;
|
||||||
|
return this.ionicStorageProvider.getApiDataFromLocally(temp,'getSalesPDSectionData').subscribe(rr=>{
|
||||||
|
console.log(rr)
|
||||||
|
// debugger
|
||||||
|
let curr_section_data =rr
|
||||||
|
if(rr.dataStatus && rr.records && rr.records.length > 0) {
|
||||||
|
curr_section_data = rr.records.filter(vv=>vv.section_id == params.section_id)
|
||||||
|
if(curr_section_data) {
|
||||||
|
curr_section_data = {dataStatus:true,status:200,records:curr_section_data}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(curr_section_data,params)
|
||||||
|
// debugger;
|
||||||
|
observer.next(curr_section_data);
|
||||||
|
observer.complete();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
listSMCCreditPD():Observable<any> {
|
||||||
|
let lender_id:any=localStorage.getItem("user_details")
|
||||||
|
lender_id=JSON.parse(lender_id).fk_entity_id;
|
||||||
|
let params = {'lender_id':lender_id}
|
||||||
|
// let params = new HttpParams().set("paramName",value) //Create new HttpParams
|
||||||
|
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||||
|
return this.http.get(this.apiUrl+'listSMCCreditPD/'+lender_id).map(res=>{
|
||||||
|
this.ionicStorageProvider.checkAndInsertApiDataLocally(res,params,'listSMCCreditPD');
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return this.ionicStorageProvider.getApiDataFromLocally(params,'listSMCCreditPD');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
saveSMCCreditPD(params1) {
|
||||||
|
let result_from_api:any;
|
||||||
|
let userid:any=localStorage.getItem("user_details")
|
||||||
|
userid=JSON.parse(userid).userid;
|
||||||
|
let params:any={"smc_credit_pd":this.curr_credit_pd_data.smc_credit_pd == null ? '' : this.curr_credit_pd_data.smc_credit_pd
|
||||||
|
,"fk_sales_pd_id":this.curr_credit_pd_data.fk_sales_pd_id,"lender_id":this.curr_credit_pd_data.lender_id,"product_id":this.curr_credit_pd_data.product_id,"smc_credit_pd_type":this.curr_credit_pd_data.smc_credit_pd_type,"createdby":userid,"status":params1.status}
|
||||||
|
console.log(params)
|
||||||
|
// debugger;
|
||||||
|
let modified_values =params;
|
||||||
|
return Observable.create((observer:any)=>{
|
||||||
|
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||||
|
return this.http.post(this.apiUrl+'saveSMCCreditPD',{records:params}).pipe().subscribe(result => {
|
||||||
|
// let result = {dataStatus:false,records:{}};
|
||||||
|
result_from_api =result
|
||||||
|
// else{
|
||||||
|
if(!params.hasOwnProperty('status') && params.status != 'COMPLETED') {
|
||||||
|
if(params.smc_credit_pd != null) {
|
||||||
|
modified_values.smc_credit_pd = params.smc_credit_pd
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
modified_values.smc_credit_pd = result['records']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(params.hasOwnProperty('status') && params.status == 'COMPLETED') {
|
||||||
|
if(!result_from_api.hasOwnProperty('pd_status') && result_from_api['pd_status'] != 'DRAFT'){
|
||||||
|
this.offlineManagerProvider.deleteCompletedPD(params.smc_credit_pd).then(rd=>{
|
||||||
|
observer.next(result_from_api);
|
||||||
|
observer.complete();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
observer.next(result_from_api);
|
||||||
|
observer.complete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.checkAndCreatePDLocally(modified_values,params,'online').then(lc=>{
|
||||||
|
|
||||||
|
observer.next(result_from_api);
|
||||||
|
observer.complete();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else if(params.hasOwnProperty('status') && params.status == 'COMPLETED') {
|
||||||
|
let pd_id_key =this.offlineManagerProvider.getThePDType(modified_values.smc_credit_pd)
|
||||||
|
this.offlineManagerProvider.checkTheExistingPDLocally(modified_values.smc_credit_pd,pd_id_key).then(result=>{
|
||||||
|
console.log(result)
|
||||||
|
if(result && result.hasOwnProperty('section_datas') && result.section_datas.length > 0){
|
||||||
|
// let product_id = localStorage.getItem('product_id_salesPD');
|
||||||
|
let pd_section_datas = result.section_datas.filter(val=>val.section_id != 'all').map(val1=>val1.section_name)
|
||||||
|
let template_sections:any = this.raw_credit_pd_template
|
||||||
|
template_sections = JSON.parse(JSON.stringify(template_sections));
|
||||||
|
template_sections = template_sections.sections.map(val1=>val1.section_name)
|
||||||
|
console.log(template_sections,pd_section_datas);
|
||||||
|
if(template_sections.length != pd_section_datas.length){
|
||||||
|
let unsavedSections = template_sections.filter(function(item) {
|
||||||
|
return !pd_section_datas.includes(item);
|
||||||
|
})
|
||||||
|
// let unsavedSections = template_sections.filter(o => pd_section_datas.some(({section_id,name}) => o.section_id != section_id));
|
||||||
|
console.log(unsavedSections);
|
||||||
|
let unsavedObj:any=[]
|
||||||
|
unsavedSections.forEach((val,index)=>{
|
||||||
|
unsavedObj.push({id:index,sectin_name:val})
|
||||||
|
})
|
||||||
|
if(unsavedSections.length > 0) {
|
||||||
|
let local_result = {
|
||||||
|
'pd_status': 'DRAFT',
|
||||||
|
'records':unsavedObj,
|
||||||
|
'dataStatus':true
|
||||||
|
}
|
||||||
|
observer.next(local_result);
|
||||||
|
observer.complete();
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let req_params = {url:this.apiUrl+'saveSMCCreditPD',
|
||||||
|
params:JSON.stringify({records:params}),method:'POST'}
|
||||||
|
this.checkAndCreatePDLocally(modified_values,params,'offline',req_params).then(lc=>{
|
||||||
|
console.log("last offline",lc);
|
||||||
|
if(params.hasOwnProperty('status') && params.status != 'COMPLETED') {
|
||||||
|
result_from_api ={dataStatus:true,records:lc.local_pd_id}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
result_from_api = {dataStatus:true,records:true}
|
||||||
|
}
|
||||||
|
console.log("at last ",result_from_api,params);
|
||||||
|
// this.insertData_Replace('sales_pd_id_PRIMARYKEY',lc.local_pd_id).then(resul=>{
|
||||||
|
observer.next(result_from_api);
|
||||||
|
observer.complete();
|
||||||
|
// })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
if(params.hasOwnProperty('status') && params.status != 'COMPLETED') {
|
||||||
|
modified_values.smc_credit_pd = null
|
||||||
|
}
|
||||||
|
console.log("offine",params,modified_values)
|
||||||
|
let req_params = {url:this.apiUrl+'saveSMCCreditPD',
|
||||||
|
params:JSON.stringify({records:params}),method:'POST'}
|
||||||
|
let dd = {product_id:modified_values.product_id,lender_id:modified_values.lender_id}
|
||||||
|
this.getProductAbbrbyId(dd).then(product_abbr=>{
|
||||||
|
modified_values.abbr = product_abbr
|
||||||
|
|
||||||
|
this.checkAndCreatePDLocally(modified_values,params,'offline',req_params).then(lc=>{
|
||||||
|
console.log("last offline",lc);
|
||||||
|
if(params.hasOwnProperty('status') && params.status != 'COMPLETED') {
|
||||||
|
result_from_api ={dataStatus:true,records:lc.local_pd_id}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
result_from_api = {dataStatus:true,records:true}
|
||||||
|
}
|
||||||
|
console.log("at last ",result_from_api,params);
|
||||||
|
// this.insertData_Replace('sales_pd_id_PRIMARYKEY',lc.local_pd_id).then(resul=>{
|
||||||
|
observer.next(result_from_api);
|
||||||
|
observer.complete();
|
||||||
|
// })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// observer.next(result_from_api);
|
||||||
|
// observer.complete();
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
loadSalesPDTemplate():Observable<any> {
|
||||||
|
let lender_id:any=localStorage.getItem("user_details")
|
||||||
|
lender_id=JSON.parse(lender_id).fk_entity_id;
|
||||||
|
let params = {"records":{"lender_id":lender_id,"product_id":this.curr_credit_pd_data.product_id,"sales_pd_type":this.curr_credit_pd_data.smc_credit_pd_type,"pd_type":"2"}}
|
||||||
|
return Observable.create((observer:any)=>{
|
||||||
|
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||||
|
return this.http.post(this.apiUrl+'loadSalesPDTemplate',params).map((res:any)=>{
|
||||||
|
if(res['dataStatus'] && res.hasOwnProperty('records') && res.records.hasOwnProperty('template')){
|
||||||
|
this.raw_credit_pd_template = res.records.template
|
||||||
|
return this.ionicStorageProvider.checkAndInsertApiDataLocally(res,params,'loadSalesPDTemplate',true).then(res=>{
|
||||||
|
observer.next(res)
|
||||||
|
observer.complete();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
observer.next(res)
|
||||||
|
observer.complete();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this.ionicStorageProvider.getApiDataFromLocally(params,'loadSalesPDTemplate').subscribe(result=>{
|
||||||
|
observer.next(result)
|
||||||
|
observer.complete();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
saveSMCCreditPDsection(params1):Observable<any> {
|
||||||
|
let userid:any=localStorage.getItem("user_details")
|
||||||
|
userid=JSON.parse(userid).userid;
|
||||||
|
let params = {"smc_credit_pd":this.curr_credit_pd_data.smc_credit_pd,"lender_id":this.curr_credit_pd_data.lender_id,"product_id":this.curr_credit_pd_data.product_id,"fk_createdby":userid,"geo_location":"","section_id":params1.section_id,"questions":params1.questions,"is_complete":"0"}
|
||||||
|
return Observable.create((observer:Observer<any>)=>{
|
||||||
|
let key_value = this.curr_credit_pd_data.smc_credit_pd
|
||||||
|
let values={smc_credit_pd:key_value,dataStatus:true}
|
||||||
|
let section_data=JSON.stringify({section_id:params.section_id,section_name:params1.section_name,onsubmit:null,questions:params.questions})
|
||||||
|
let modified_params:any = params
|
||||||
|
console.log("###################$%%",(key_value != null ? (typeof(key_value) == 'string' ? !key_value.includes('local') : true ) : true));
|
||||||
|
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online && (key_value != null ? (typeof(key_value) == 'string' ? !key_value.includes('local') : true ) : true) ) {
|
||||||
|
return this.http.post(this.apiUrl+'saveSMCCreditPDsection',{records:params}).subscribe(response=>{
|
||||||
|
// delete modified_params.questions
|
||||||
|
modified_params.is_synced = true;
|
||||||
|
modified_params.section_data = section_data
|
||||||
|
if(modified_params.section_id != '9'){
|
||||||
|
this.checkAndCreatePDLocally(values,'','online','',modified_params).then(res=>{
|
||||||
|
observer.next(response)
|
||||||
|
observer.complete()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
observer.next(response)
|
||||||
|
observer.complete()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else if(modified_params.section_id != '9'){
|
||||||
|
// console.log("#######params",modified_params)
|
||||||
|
let offline_params = modified_params
|
||||||
|
offline_params.request_items={url:this.apiUrl+'saveSalesPDsection',
|
||||||
|
params:JSON.stringify({records:params}),method:'POST'}
|
||||||
|
offline_params.is_synced = false
|
||||||
|
offline_params.section_data = section_data
|
||||||
|
console.log(offline_params.request_items.params)
|
||||||
|
this.checkAndCreatePDLocally(values,'','offline','',offline_params).then(res=>{
|
||||||
|
observer.next({dataStatus:true});
|
||||||
|
observer.complete()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
observer.next({dataStatus:true});
|
||||||
|
observer.complete()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// })
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
getSalesPDImgDataCusLink(params) {
|
||||||
|
return this.http.post(this.apiUrl+'getSalesPDImgDataCusLink',params)
|
||||||
|
}
|
||||||
|
getSMCCreditPDSectionData(params) {
|
||||||
|
return Observable.create((observer:Observer<any>)=>{
|
||||||
|
this.offlineManagerProvider.getSalesPDSectionLocally(params).then(result => {
|
||||||
|
if(result != undefined) {
|
||||||
|
let modified_result:any={};
|
||||||
|
if(params.section_id == 'all'){
|
||||||
|
modified_result = result
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
modified_result.records = [result]
|
||||||
|
modified_result.dataStatus = true
|
||||||
|
modified_result.status = 200
|
||||||
|
console.clear()
|
||||||
|
}
|
||||||
|
console.log(modified_result)
|
||||||
|
observer.next(modified_result);
|
||||||
|
observer.complete()
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||||
|
let values={smc_credit_pd:params.smc_credit_pd,dataStatus:true}
|
||||||
|
return this.http.post(this.apiUrl+'getSMCCreditPDSectionData',{records:params}).subscribe(result =>{
|
||||||
|
let modified_values:any =result
|
||||||
|
modified_values.section_id = params.section_id
|
||||||
|
if(result['dataStatus']) {
|
||||||
|
if(params.section_id != 'all') {
|
||||||
|
modified_values = result['records'][0]
|
||||||
|
modified_values.is_synced = true
|
||||||
|
}
|
||||||
|
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||||
|
this.checkAndCreatePDLocally(values,'','online','',modified_values).then(res=>{
|
||||||
|
observer.next(result);
|
||||||
|
observer.complete()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
observer.next(result);
|
||||||
|
observer.complete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
observer.next(result);
|
||||||
|
observer.complete()
|
||||||
|
}
|
||||||
|
},err=>{
|
||||||
|
observer.next(err);
|
||||||
|
observer.complete();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log("No Data Found#########");
|
||||||
|
// observer.error({err_msg:'No Data Found'})
|
||||||
|
// Observable.throw(new Error('No Data Found'))
|
||||||
|
observer.next({dataStatus:false})
|
||||||
|
observer.complete()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
saveSMCCreditPDImage(params) {
|
||||||
|
return this.http.post(this.apiUrl+'saveSMCCreditPDImage',{records:params})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
insertData_Replace(key,data){
|
||||||
|
// console.log(key)
|
||||||
|
return this.storage.set(key,data);
|
||||||
|
}
|
||||||
|
// insertData_noReplace(key,data){
|
||||||
|
// // this.getData(key).then(res=>{
|
||||||
|
// let temp=[]
|
||||||
|
// if(res){
|
||||||
|
// temp=res
|
||||||
|
// temp.push(data)
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// temp=[data]
|
||||||
|
// }
|
||||||
|
// return this.storage.set(this.getKey(key),temp)
|
||||||
|
// // })
|
||||||
|
// }
|
||||||
|
getData_fromLocal(key){
|
||||||
|
// console.log("get data key",this.getKey(key));
|
||||||
|
// console.log("get data provider",this.storage.get(key))
|
||||||
|
// console.log("all key in storage",this.storage.keys())
|
||||||
|
return this.storage.get(key);
|
||||||
|
}
|
||||||
|
clearLocalData(){
|
||||||
|
this.storage.clear().then(res=>{
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
clear_local_key(key){
|
||||||
|
return this.storage.remove(key)
|
||||||
|
}
|
||||||
|
getProductAbbrbyId(obj) {
|
||||||
|
if(obj){
|
||||||
|
return new Promise((resolve,reject)=>{
|
||||||
|
return this.getEntityPreferences(obj.lender_id).subscribe(result=>{
|
||||||
|
if(result && result['dataStatus']) {
|
||||||
|
let productforLender = result['records'].salespd_products
|
||||||
|
if(productforLender && productforLender.length > 0) {
|
||||||
|
let product_abbr = productforLender.filter(val=>val.product_id == obj.product_id).map(va=>va.product_abbr)[0]
|
||||||
|
resolve(product_abbr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getEntityPreferences(entity_id){
|
||||||
|
// return this.http.get(this.apiurl+'getEntityPreferences/'+entity_id);
|
||||||
|
let params = {entity_id:entity_id}
|
||||||
|
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||||
|
return this.http.get(this.apiUrl+'getEntityPreferences/'+entity_id).map(result=>{
|
||||||
|
this.ionicStorageProvider.checkAndInsertApiDataLocally(result,params,'getEntityPreferences');
|
||||||
|
return result;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this.ionicStorageProvider.getApiDataFromLocally(params,'getEntityPreferences');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSectionDataLocally(params,form_structure){
|
||||||
|
return Observable.create((observer:Observer<any>) => {
|
||||||
|
// this.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(key_value=>{
|
||||||
|
let key_value = this.curr_credit_pd_data.smc_credit_pd
|
||||||
|
// params.location=geoCords
|
||||||
|
params.fk_sales_pd_id=key_value
|
||||||
|
let values={smc_credit_pd:key_value,dataStatus:true}
|
||||||
|
let section_data=JSON.stringify({section_id:form_structure.section_id,section_name:form_structure.section_name,onsubmit:null,questions:form_structure.questions})
|
||||||
|
let modified_params = form_structure
|
||||||
|
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online && (key_value != null ? (typeof(key_value) == 'string' ? !key_value.includes('local') : true) : true)) {
|
||||||
|
modified_params.is_synced = true
|
||||||
|
modified_params.section_data = section_data
|
||||||
|
this.checkAndCreatePDLocally(values,'','online','',modified_params).then(res=>{
|
||||||
|
observer.next('');
|
||||||
|
observer.complete();
|
||||||
|
})
|
||||||
|
// },err=>{
|
||||||
|
// console.clear();
|
||||||
|
// // console.log("err>>>>",err)
|
||||||
|
// observer.next(err);
|
||||||
|
// observer.complete();
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// console.log("#######params",modified_params)
|
||||||
|
let offline_params = modified_params
|
||||||
|
offline_params.request_items=[{url:this.apiUrl+'saveSalesPDImage',
|
||||||
|
params:JSON.stringify({records:params}),method:'POST'}]
|
||||||
|
offline_params.is_synced = false
|
||||||
|
offline_params.section_data = section_data
|
||||||
|
console.log(offline_params)
|
||||||
|
this.checkAndCreatePDLocally(values,'','offline','',offline_params).then(res=>{
|
||||||
|
observer.next({dataStatus:true});
|
||||||
|
observer.complete()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
checkAndCreatePDLocally(modified_values,params,connection_status,request_items?,section_data?) {
|
||||||
|
let paramsCompare;
|
||||||
|
if(modified_values.smc_credit_pd != null && modified_values.smc_credit_pd != undefined && typeof(modified_values.smc_credit_pd) == 'string') {
|
||||||
|
console.log(modified_values.smc_credit_pd);
|
||||||
|
console.log("######### local pd id ",modified_values.smc_credit_pd.includes('local'))
|
||||||
|
if(modified_values.smc_credit_pd.includes('local')) {
|
||||||
|
modified_values.local_pd_id=modified_values.smc_credit_pd
|
||||||
|
modified_values.smc_credit_pd =null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(modified_values.smc_credit_pd != null) {
|
||||||
|
return this.offlineManagerProvider.checkTheExistingPDLocally(modified_values.smc_credit_pd,'smc_credit_pd').then(result=>{
|
||||||
|
console.log("offline result",result);
|
||||||
|
// debugger;
|
||||||
|
if(result || result != undefined) {
|
||||||
|
paramsCompare = {smc_credit_pd : modified_values.smc_credit_pd}
|
||||||
|
modified_values = result
|
||||||
|
if(params.hasOwnProperty('status') && params.stautus == 'COMPLETED') {
|
||||||
|
modified_values = result
|
||||||
|
modified_values.dataStatus = true
|
||||||
|
}
|
||||||
|
if(section_data) {
|
||||||
|
if(section_data.section_id == '1' && section_data.hasOwnProperty('questions') && section_data.questions.filter(val=>val.question_key == 'company_name').length > 0) {
|
||||||
|
let company_ques_index = section_data.questions.findIndex(val=>val.question_key == "company_name")
|
||||||
|
modified_values.applicant_name = section_data.questions[company_ques_index].answer_value
|
||||||
|
}
|
||||||
|
|
||||||
|
let update_section_datas =this.offlineManagerProvider.updateSectionData(section_data,result)
|
||||||
|
modified_values.section_datas = update_section_datas
|
||||||
|
if(modified_values.section_datas.length > 0 && modified_values.section_datas.filter(val=>val.is_synced == false).length > 0){
|
||||||
|
modified_values.is_all_section_synced = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(params.hasOwnProperty('status') && params.status == 'COMPLETED') {
|
||||||
|
if(connection_status == 'offline'){
|
||||||
|
modified_values.is_pd_completed = true;
|
||||||
|
modified_values.is_pd_completed_sync = false
|
||||||
|
modified_values.status = '_COMPLETED'
|
||||||
|
modified_values.pd_complete_request_items = request_items
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
modified_values.is_pd_completed = true;
|
||||||
|
modified_values.is_pd_completed_sync = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// this.offlineManagerProvider.getlocalPDData(modified_values,connection_status,request_items)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// console.clear();
|
||||||
|
// console.log("check c",modified_values)
|
||||||
|
paramsCompare = {smc_credit_pd:String(modified_values.smc_credit_pd)}
|
||||||
|
if(section_data) {
|
||||||
|
if(section_data.section_id == '1' && section_data.hasOwnProperty('questions') && section_data.questions.filter(val=>val.question_key == 'company_name').length > 0) {
|
||||||
|
let company_ques_index = section_data.questions.findIndex(val=>val.question_key == "company_name")
|
||||||
|
modified_values.applicant_name = section_data.questions[company_ques_index].answer_value
|
||||||
|
}
|
||||||
|
|
||||||
|
let update_section_datas =this.offlineManagerProvider.updateSectionData(section_data,result)
|
||||||
|
modified_values.section_datas = update_section_datas
|
||||||
|
if(modified_values.section_datas.length > 0 && modified_values.section_datas.filter(val=>val.is_synced == false).length > 0){
|
||||||
|
modified_values.is_all_section_synced = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.offlineManagerProvider.getlocalPDData(modified_values,connection_status,request_items)
|
||||||
|
}
|
||||||
|
return this.ionicStorageProvider.checkAndInsertApiDataLocally(modified_values,paramsCompare,pd_key,true).then(res=>{
|
||||||
|
return modified_values
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this.offlineManagerProvider.getTheLengthOfLocalPDs().then(Res=>{
|
||||||
|
return this.offlineManagerProvider.checkTheExistingPDLocally(modified_values.local_pd_id,'local_pd_id').then(result=>{
|
||||||
|
console.log("local pd id",result,params.local_pd_id);
|
||||||
|
if((result || result != undefined) && modified_values.local_pd_id != undefined) {
|
||||||
|
paramsCompare = {local_pd_id:modified_values.local_pd_id}
|
||||||
|
modified_values = result
|
||||||
|
if(section_data) {
|
||||||
|
if(section_data.section_id == '1' && section_data.hasOwnProperty('questions') && section_data.questions.filter(val=>val.question_key == 'company_name').length > 0) {
|
||||||
|
let company_ques_index = section_data.questions.findIndex(val=>val.question_key == "company_name")
|
||||||
|
modified_values.applicant_name = section_data.questions[company_ques_index].answer_value
|
||||||
|
}
|
||||||
|
|
||||||
|
let update_section_datas =this.offlineManagerProvider.updateSectionData(section_data,result)
|
||||||
|
modified_values.section_datas = update_section_datas
|
||||||
|
if(modified_values.section_datas.length > 0 && modified_values.section_datas.filter(val=>val.is_synced == false).length > 0){
|
||||||
|
modified_values.is_all_section_synced = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(params.hasOwnProperty('status') && params.status == 'COMPLETED') {
|
||||||
|
if(connection_status == 'offline'){
|
||||||
|
modified_values.is_pd_completed = true;
|
||||||
|
modified_values.is_pd_completed_sync = false
|
||||||
|
modified_values.pd_complete_request_items = request_items
|
||||||
|
modified_values.status = '_COMPLETED'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
modified_values.is_pd_completed = true;
|
||||||
|
modified_values.is_pd_completed_sync = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// this.offlineManagerProvider.getlocalPDData(modified_values,connection_status,request_items)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log("Else##########",Res)
|
||||||
|
let pd_id:string= '1'
|
||||||
|
if(Res){
|
||||||
|
pd_id =Res
|
||||||
|
}
|
||||||
|
paramsCompare = {local_pd_id:pd_id}
|
||||||
|
modified_values.local_pd_id = pd_id
|
||||||
|
if(section_data) {
|
||||||
|
if(section_data.section_id == '1' && section_data.hasOwnProperty('questions') && section_data.questions.filter(val=>val.question_key == 'company_name').length > 0) {
|
||||||
|
let company_ques_index = section_data.questions.findIndex(val=>val.question_key == "company_name")
|
||||||
|
modified_values.applicant_name = section_data.questions[company_ques_index].answer_value
|
||||||
|
}
|
||||||
|
|
||||||
|
let update_section_datas =this.offlineManagerProvider.updateSectionData(section_data,result)
|
||||||
|
modified_values.section_datas = update_section_datas
|
||||||
|
if(modified_values.section_datas.length > 0 && modified_values.section_datas.filter(val=>val.is_synced == false).length > 0){
|
||||||
|
modified_values.is_all_section_synced = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.offlineManagerProvider.getlocalPDData(modified_values,connection_status,request_items)
|
||||||
|
|
||||||
|
}
|
||||||
|
return this.ionicStorageProvider.checkAndInsertApiDataLocally(modified_values,paramsCompare,pd_key,true).then(res=>{
|
||||||
|
return modified_values
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getStakeholderInfo() {
|
||||||
|
return Observable.create((observer:any)=>{
|
||||||
|
let sec3param = {"smc_credit_pd":this.curr_credit_pd_data.smc_credit_pd,"section_id":"3"}
|
||||||
|
return this.offlineManagerProvider.getSalesPDSectionLocally(sec3param).then(result => {
|
||||||
|
console.log(result);
|
||||||
|
// debugger;
|
||||||
|
if(result != undefined) {
|
||||||
|
let modified_result:any={};
|
||||||
|
if(sec3param.section_id == 'all'){
|
||||||
|
modified_result = result
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
modified_result.records = [result]
|
||||||
|
modified_result.dataStatus = true
|
||||||
|
modified_result.status = 200
|
||||||
|
console.clear()
|
||||||
|
}
|
||||||
|
console.log(modified_result)
|
||||||
|
observer.next(modified_result);
|
||||||
|
observer.complete()
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
observer.next({dataStatus:false,status:400})
|
||||||
|
observer.complete();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,413 @@
|
|||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { IonicStorageProvider } from '../../../../providers/ionic-storage/ionic-storage';
|
||||||
|
import { ToastProvider } from '../../../../providers/common-provider/toast';
|
||||||
|
import { LoadingProvider } from '../../../../providers/common-provider/loading';
|
||||||
|
import { forkJoin } from 'rxjs';
|
||||||
|
import { Storage } from '@ionic/storage';
|
||||||
|
|
||||||
|
/*
|
||||||
|
Generated class for the OfflineManagerCreditProvider provider.
|
||||||
|
|
||||||
|
See https://angular.io/guide/dependency-injection for more info on providers
|
||||||
|
and Angular DI.
|
||||||
|
*/
|
||||||
|
const pd_key = 'local_credit_PDs'
|
||||||
|
@Injectable()
|
||||||
|
export class OfflineManagerCreditProvider {
|
||||||
|
|
||||||
|
constructor(private ionicStorage:Storage,private _http:HttpClient,private ionicStorageProvider:IonicStorageProvider,private toastProvider:ToastProvider,
|
||||||
|
private loaderProvider:LoadingProvider) {
|
||||||
|
console.log('Hello OfflineManagerCreditProvider Provider');
|
||||||
|
}
|
||||||
|
checkTheExistingPDLocally(key_value,key_to_chek) {
|
||||||
|
return this.ionicStorage.get('local_credit_PDs').then(result=> {
|
||||||
|
if(result) {
|
||||||
|
for(let i=0; i<result.length;i++) {
|
||||||
|
let result_obj =result[i]
|
||||||
|
console.log(result_obj)
|
||||||
|
if(result_obj && result_obj.hasOwnProperty(key_to_chek) && result_obj[key_to_chek] == key_value) {
|
||||||
|
return result_obj
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
getTheLengthOfLocalPDs() {
|
||||||
|
return this.ionicStorage.get('local_credit_PDs').then(result=> {
|
||||||
|
let count=1
|
||||||
|
if(result) {
|
||||||
|
count = result.length+1
|
||||||
|
return 'local-'+count
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return 'local-'+count
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
getlocalPDData(modified_values,connection_status,request_items?) {
|
||||||
|
if(connection_status == 'online') {
|
||||||
|
console.log("else part")
|
||||||
|
modified_values.is_pd_synced = true;
|
||||||
|
modified_values.is_all_section_synced = null
|
||||||
|
modified_values.is_pd_completed = false
|
||||||
|
modified_values.local_pd_id = null
|
||||||
|
modified_values.dataStatus = true
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
console.log("else part")
|
||||||
|
modified_values.is_pd_synced = false;
|
||||||
|
modified_values.is_all_section_synced = null
|
||||||
|
modified_values.is_pd_completed = false
|
||||||
|
modified_values.is_pd_completed_sync = false
|
||||||
|
modified_values.dataStatus = true
|
||||||
|
modified_values.createdon = new Date();
|
||||||
|
modified_values.status = 'STARTED'
|
||||||
|
modified_values.requests = request_items
|
||||||
|
}
|
||||||
|
return modified_values
|
||||||
|
}
|
||||||
|
addcompleteRequest() {
|
||||||
|
|
||||||
|
}
|
||||||
|
updateSectionData(curr_section,pd_data) {
|
||||||
|
if(pd_data != undefined && pd_data.hasOwnProperty('section_datas') && pd_data.section_datas) {
|
||||||
|
// if(curr_section.sales_pd_id != null) {
|
||||||
|
if(pd_data.section_datas.filter(val=>val.section_id == curr_section.section_id).length > 0){
|
||||||
|
let index = pd_data.section_datas.findIndex(val=>val.section_id == curr_section.section_id)
|
||||||
|
console.log("index $#####",index,curr_section,pd_data)
|
||||||
|
// debugger
|
||||||
|
// pd_data.section_datas[index] = curr_section
|
||||||
|
if(curr_section.section_id == '9' && curr_section.hasOwnProperty('request_items') && curr_section.request_items != null) {
|
||||||
|
let request_items_fresh:any;
|
||||||
|
if(pd_data.section_datas[index].hasOwnProperty('request_items') && pd_data.section_datas[index].request_items != null && pd_data.section_datas[index].request_items != undefined) {
|
||||||
|
pd_data.section_datas[index].request_items.push(curr_section.request_items[0])
|
||||||
|
request_items_fresh = pd_data.section_datas[index].request_items
|
||||||
|
console.log("!st")
|
||||||
|
}
|
||||||
|
else if(pd_data.section_datas[index].request_items == undefined){
|
||||||
|
request_items_fresh = curr_section.request_items
|
||||||
|
console.log("2nt")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
request_items_fresh = pd_data.section_datas[index].request_items
|
||||||
|
console.log("3rt")
|
||||||
|
}
|
||||||
|
pd_data.section_datas[index] = curr_section
|
||||||
|
pd_data.section_datas[index].request_items = request_items_fresh
|
||||||
|
console.log(pd_data.section_datas[index],request_items_fresh)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pd_data.section_datas[index] = curr_section
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
pd_data.section_datas.push(curr_section)
|
||||||
|
}
|
||||||
|
console.log("Befor update#######33",pd_data.section_datas)
|
||||||
|
let update_section_datas = this.updateSectionStatus(curr_section,pd_data.section_datas)
|
||||||
|
console.log("#########update_sec_data",pd_data.section_datas,update_section_datas);
|
||||||
|
return update_section_datas
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
let dummy_section_datas = [curr_section]
|
||||||
|
console.log("Befor Inseret#######33",dummy_section_datas)
|
||||||
|
let update_section_datas = this.updateSectionStatus(curr_section,dummy_section_datas)
|
||||||
|
return update_section_datas
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
updateSectionStatus(curr_section,section_datas) {
|
||||||
|
|
||||||
|
if(section_datas.length > 0 && (section_datas.filter(val=>val.section_id == "all").length) > 0){
|
||||||
|
// let section_status_arr= section_datas.filter(val=>val.section_id == 'all')[0]
|
||||||
|
for(let i=0;i<section_datas.length;i++) {
|
||||||
|
let section_status_arr=section_datas[i]
|
||||||
|
if(section_status_arr && section_status_arr.section_id == 'all'){
|
||||||
|
console.log("section Status update####################")
|
||||||
|
if(section_status_arr.records.filter(val=>val.section_id == curr_section.section_id).length > 0) {
|
||||||
|
let findIndex = section_status_arr.records.findIndex(val=>val.section_id == curr_section.section_id)
|
||||||
|
section_status_arr.records[findIndex]
|
||||||
|
section_datas[i].records[findIndex].is_synced = curr_section.is_synced ? curr_section.is_synced : false
|
||||||
|
return section_datas
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
section_datas[i].records.push({
|
||||||
|
smc_credit_pd: curr_section.smc_credit_pd,
|
||||||
|
section_id: curr_section.section_id,
|
||||||
|
status: "1",
|
||||||
|
is_synced:curr_section.is_synced ? curr_section.is_synced : false})
|
||||||
|
return section_datas
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log("section Status INSERT####################")
|
||||||
|
section_datas.push({
|
||||||
|
dataStatus:true,
|
||||||
|
status:true,
|
||||||
|
section_id:'all',
|
||||||
|
records:[{smc_credit_pd:curr_section.smc_credit_pd,section_id:curr_section.section_id,status:'1', is_synced:curr_section.is_synced}],
|
||||||
|
is_synced:curr_section.is_synced ? curr_section.is_synced : false
|
||||||
|
})
|
||||||
|
return section_datas
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getSalesPDSectionLocally(params) {
|
||||||
|
let keyToCheck = 'smc_credit_pd'
|
||||||
|
if(typeof(params.smc_credit_pd) == 'string' && params.smc_credit_pd.includes('local')) {
|
||||||
|
params.local_pd_id = params.smc_credit_pd
|
||||||
|
keyToCheck = 'local_pd_id'
|
||||||
|
}
|
||||||
|
return this.checkTheExistingPDLocally(params[keyToCheck],keyToCheck).then(result=>{
|
||||||
|
if(result) {
|
||||||
|
if(result.hasOwnProperty('section_datas') && result.section_datas) {
|
||||||
|
if(result.section_datas.filter(val=>val.section_id == params.section_id).length !=0) {
|
||||||
|
let index = result.section_datas.findIndex(val=>val.section_id == params.section_id)
|
||||||
|
return result.section_datas[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
presentLoader(msg) {
|
||||||
|
|
||||||
|
this.loaderProvider.salesPDLoader(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
//MAIN FUNCTION FOR ONLINE SYNCING
|
||||||
|
|
||||||
|
checkAndSyncPDWithSection(pd_primary_key) {
|
||||||
|
console.log(pd_primary_key)
|
||||||
|
return new Promise((resolve,reject) =>{
|
||||||
|
let pd_id_key =this.getThePDType(pd_primary_key)
|
||||||
|
// if(pd_id_key == 'local_pd_id') {
|
||||||
|
// PD TO BE SYNCED
|
||||||
|
// console.log("entered")
|
||||||
|
return this.checkTheExistingPDLocally(pd_primary_key,pd_id_key).then(result=>{
|
||||||
|
console.log(result)
|
||||||
|
|
||||||
|
if(pd_id_key == 'local_pd_id') {
|
||||||
|
this.presentLoader('Creating PD...')
|
||||||
|
let request_arr:any =[]
|
||||||
|
request_arr.push(result.requests)
|
||||||
|
console.log(request_arr);
|
||||||
|
return this.sendRequests(request_arr,null).subscribe((api_res:any)=>{
|
||||||
|
console.log("Request successfully sended",api_res);
|
||||||
|
if(api_res && api_res.length > 0) {
|
||||||
|
api_res=api_res[0]
|
||||||
|
}
|
||||||
|
this.loaderProvider.dismissLoader();
|
||||||
|
return this.updatePDData(pd_primary_key,result,{is_pd_synced:true,smc_credit_pd:api_res['records'],local_pd_id:null,params:{smc_credit_pd:String(api_res['records'])}}).then(local_result => {
|
||||||
|
console.log("local pd is updated",local_result)
|
||||||
|
|
||||||
|
// FOR SECTION TO BE SAVED
|
||||||
|
return this.checkAndSyncPDWithSection(api_res['records']).then(result=>{
|
||||||
|
console.log("Final complete of syncing",result);
|
||||||
|
resolve(result)
|
||||||
|
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},err=>{
|
||||||
|
console.log(err);
|
||||||
|
this.loaderProvider.dismissLoader()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else if(result.hasOwnProperty('section_datas') && result.section_datas &&
|
||||||
|
result.section_datas.filter(val=>val.is_synced == false && val.section_id != 'all' && val.section_id != 'complete' && val.request_items != null).length > 0){
|
||||||
|
this.presentLoader('Sending Sections and Images....')
|
||||||
|
let section_datas= result.section_datas
|
||||||
|
let section_requests:any =[]
|
||||||
|
section_requests = section_datas.filter(val=>val.is_synced == false && val.section_id != 'all' && val.section_id != 'complete' && val.request_items != null && val.section_id != '9')
|
||||||
|
.map(sec_req=>sec_req.request_items)
|
||||||
|
console.log(section_requests);
|
||||||
|
if(section_datas.filter(val=>val.section_id == '9').length > 0 ) {
|
||||||
|
let photoSection= section_datas.filter(val=>val.section_id == '9').map(sec_req=>sec_req.request_items)[0]
|
||||||
|
if(photoSection && photoSection.length > 0) {
|
||||||
|
console.log("#####3,",photoSection)
|
||||||
|
photoSection.forEach(req_img=>{
|
||||||
|
section_requests.push(req_img)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(section_requests);
|
||||||
|
return this.sendRequests(section_requests,pd_primary_key).subscribe((api_res:any)=>{
|
||||||
|
this.loaderProvider.dismissLoader();
|
||||||
|
console.log("Request successfully sended",api_res);
|
||||||
|
section_datas.forEach(val=>{
|
||||||
|
if(val.is_synced == false && val.section_id != 'all' && val.section_id != 'complete' && val.request_items != null){
|
||||||
|
val.is_synced = true
|
||||||
|
val.request_items = null
|
||||||
|
}
|
||||||
|
if(val.section_id == 'all') {
|
||||||
|
if(val.hasOwnProperty('records') && val.records && val.records.length > 0)
|
||||||
|
val.records.forEach(sub_val=>{
|
||||||
|
sub_val.is_synced = true;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
let updated_values = {is_all_section_synced:true,section_datas:section_datas}
|
||||||
|
return this.updatePDData(pd_primary_key,result,updated_values).then(local_result => {
|
||||||
|
return this.checkAndSyncPDWithSection(pd_primary_key).then(result=>{
|
||||||
|
console.log("Final complete of syncing",result);
|
||||||
|
// let result_val:any={}
|
||||||
|
// result_val = result
|
||||||
|
// result_val.dataStatus = true
|
||||||
|
resolve(result)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},err=>{
|
||||||
|
console.log(err);
|
||||||
|
this.loaderProvider.dismissLoader()
|
||||||
|
})
|
||||||
|
// return request_arr
|
||||||
|
// this.sendRequests(request_arr).subscribe((api_res:any)=>{
|
||||||
|
// console.log("Request successfully sended",api_res);
|
||||||
|
// if(api_res && api_res.length > 0) {
|
||||||
|
// api_res=api_res[0]
|
||||||
|
// }
|
||||||
|
// return this.updatePDData(pd_primary_key,result,{is_pd_synced:true,smc_credit_pd:api_res['records'],local_pd_id:null,params:{smc_credit_pd:api_res['records']}}).then(local_result => {
|
||||||
|
// console.log("local pd is updated",local_result)
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// PD Completion
|
||||||
|
if(result.hasOwnProperty('is_pd_completed') && result.hasOwnProperty('is_pd_completed_sync')&& result.hasOwnProperty('pd_complete_request_items')
|
||||||
|
&& result.is_pd_completed == true && result.is_pd_completed_sync == false && result.pd_complete_request_items != null) {
|
||||||
|
this.presentLoader("Completing PD...")
|
||||||
|
let request_arr:any =[]
|
||||||
|
request_arr.push(result.pd_complete_request_items)
|
||||||
|
return this.sendRequests(request_arr,pd_primary_key).subscribe((api_res:any)=>{
|
||||||
|
this.loaderProvider.dismissLoader();
|
||||||
|
api_res=api_res[0]
|
||||||
|
console.log("Request successfully sended",api_res,api_res.hasOwnProperty('pd_status') && api_res['pd_status'] == 'DRAFT');
|
||||||
|
if(api_res.hasOwnProperty('pd_status') && api_res['pd_status'] == 'DRAFT'){
|
||||||
|
// this.toastProvider.setAlert("<small>Personal Discussion is not completed<small>","Some of the sections are saved as draft. Kindly check and complete that.")
|
||||||
|
|
||||||
|
let section_redirect=api_res['records']
|
||||||
|
let section_dis_names:any=[];
|
||||||
|
if(section_redirect.length > 0){
|
||||||
|
section_redirect.forEach(res=>{
|
||||||
|
section_dis_names.push(res.sectin_name)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
console.log(section_redirect);
|
||||||
|
|
||||||
|
let alert=this.toastProvider.setAlertWithOkButton("<small>Sales PD is incomplete<small>","The Following sections are not Saved <b>"+section_dis_names+'</b>')
|
||||||
|
alert.present()
|
||||||
|
// alert.onDidDismiss(()=>{
|
||||||
|
// this.redirect_to_section('')
|
||||||
|
// })
|
||||||
|
resolve ({dataStatus:false,msg:"Unable to Complete the PD"})
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// let updated_values = {is_pd_completed_sync:true,pd_complete_request_items:null,status:'COMPLETED'}
|
||||||
|
// return this.updatePDData(pd_primary_key,result,updated_values).then(local_result => {
|
||||||
|
// resolve ({dataStatus:true,is_all_synced:true})
|
||||||
|
// })
|
||||||
|
return this.deleteCompletedPD(pd_primary_key).then(vl=>{
|
||||||
|
resolve ({dataStatus:true,is_all_synced:true})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},err=>{
|
||||||
|
console.log(err);
|
||||||
|
this.loaderProvider.dismissLoader()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolve ({dataStatus:true,is_all_synced:true})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// this.
|
||||||
|
})
|
||||||
|
})
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// // FUNCTION FOR SECTION SAVING
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
deleteCompletedPD(pd_id) {
|
||||||
|
return this.ionicStorage.get(pd_key).then(result => {
|
||||||
|
let result_arr = result
|
||||||
|
if(result_arr && result_arr.length > 0) {
|
||||||
|
let updated_local_pds = result_arr.filter(val=>val.smc_credit_pd != pd_id)
|
||||||
|
console.log(updated_local_pds)
|
||||||
|
return this.ionicStorage.set(pd_key,updated_local_pds).then(inserted_res=>{
|
||||||
|
return inserted_res
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
updatePDData(pd_primary_key,result_obj,updated_values) {
|
||||||
|
// return this.ionicStorage.get(pd_key).then(result=>{
|
||||||
|
// if(result && result.length > 0) {
|
||||||
|
// // for(let val_obj of result) {
|
||||||
|
// let pd_id_key =this.getThePDType(pd_primary_key)
|
||||||
|
// let findIndex = result.findIndex(val=>val[pd_id_key] == pd_primary_key)
|
||||||
|
// if(findIndex) {
|
||||||
|
// result[findIndex]
|
||||||
|
// Object.assign(result[findIndex],updated_values)
|
||||||
|
// console.log("changed values",result[findIndex])
|
||||||
|
// }
|
||||||
|
// // }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
if(result_obj) {
|
||||||
|
let pd_id_key =this.getThePDType(pd_primary_key)
|
||||||
|
Object.assign(result_obj,updated_values)
|
||||||
|
console.log(result_obj)
|
||||||
|
let paramsToCompare :any ={};
|
||||||
|
paramsToCompare[pd_id_key] = String(pd_primary_key)
|
||||||
|
console.log(paramsToCompare)
|
||||||
|
return this.ionicStorageProvider.insertDataWithoutReplace(pd_key,result_obj,paramsToCompare).then(result =>{
|
||||||
|
return result
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// local or synced pd
|
||||||
|
getThePDType(pd_id){
|
||||||
|
if(pd_id != null && typeof(pd_id) == 'string' && pd_id.includes('local')) {
|
||||||
|
return 'local_pd_id'
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return 'smc_credit_pd'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sendRequests(operations,pd_id) {
|
||||||
|
let obs = [];
|
||||||
|
for (let op of operations) {
|
||||||
|
console.log('Make one request: ', op);
|
||||||
|
let params = JSON.parse(op.params)
|
||||||
|
if(params.hasOwnProperty('records')) {
|
||||||
|
if(params.records.hasOwnProperty('smc_credit_pd')) {
|
||||||
|
params.records.smc_credit_pd = pd_id
|
||||||
|
}
|
||||||
|
else if(params.records.hasOwnProperty('fk_sales_pd_id')){
|
||||||
|
params.records.fk_sales_pd_id = pd_id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(params.hasOwnProperty('smc_credit_pd')) {
|
||||||
|
params.smc_credit_pd = pd_id
|
||||||
|
}
|
||||||
|
else if(params.hasOwnProperty('fk_sales_pd_id')){
|
||||||
|
params.fk_sales_pd_id = pd_id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let oneObs = this._http.request(op.method, op.url, {body:params});
|
||||||
|
obs.push(oneObs);
|
||||||
|
console.log(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Send out all local events and return once they are finished
|
||||||
|
return forkJoin(obs);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -191,7 +191,7 @@
|
|||||||
|
|
||||||
<div *ngIf="!pdlistaccess && !loader_access" text-center>
|
<div *ngIf="!pdlistaccess && !loader_access" text-center>
|
||||||
|
|
||||||
<h2>{{pdlistdetails}}</h2>
|
<h2 style="font-size: 20px;margin-top: 10px;">{{pdlistdetails}}</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -10,12 +10,15 @@ import { BrowserModule } from '@angular/platform-browser';
|
|||||||
import { IonicModule } from 'ionic-angular';
|
import { IonicModule } from 'ionic-angular';
|
||||||
import { MyApp } from '../../../app/app.component';
|
import { MyApp } from '../../../app/app.component';
|
||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { NumToWordsPipe } from '../../../pipes/num-to-words/num-to-words';
|
import { SharedModule } from '../../../Shared/shared.module';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [QuesTemplateComponent,NumToWordsPipe],
|
declarations: [QuesTemplateComponent],
|
||||||
imports: [MatButtonToggleModule,
|
imports: [MatButtonToggleModule,
|
||||||
|
SharedModule,
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
IonicModule.forRoot(MyApp),
|
IonicModule.forRoot(MyApp),
|
||||||
BrowserAnimationsModule,
|
BrowserAnimationsModule,
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
<div [formGroup]="searchForm" fxLayout="row wrap" fxFlex="100%" fxLayoutGap="35px" fxLayoutAlign="flex-start stretch">
|
<div [formGroup]="searchForm" fxLayout="row wrap" fxFlex="100%" fxLayoutGap="35px" fxLayoutAlign="flex-start stretch">
|
||||||
<mat-form-field style="width: 100%">
|
<mat-form-field style="width: 100%">
|
||||||
<mat-select multiple formControlName="pd_status" placeholder="PD Status">
|
<mat-select multiple formControlName="pd_status" placeholder="PD Status">
|
||||||
<mat-option *ngFor="let status of pdStatus" [value]="status">{{status}}
|
<mat-option *ngFor="let status of pdStatus" [value]="status.pd_status_name">{{status.pd_status_name}}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|||||||
@ -30,6 +30,7 @@ export class AdvanceFilterPage {
|
|||||||
PRODUCTS: any =[];
|
PRODUCTS: any =[];
|
||||||
xpandStatus:boolean=false;
|
xpandStatus:boolean=false;
|
||||||
pipe=new DatePipe('en-US');
|
pipe=new DatePipe('en-US');
|
||||||
|
is_sales_login: boolean = false;
|
||||||
constructor(private _fb:FormBuilder,public navCtrl: NavController, public navParams: NavParams,public actionSheetCtrl: ActionSheetController,private salesPDService:SalesPdProvider,private toastProvider:ToastProvider,private loaderProvider:LoadingProvider,private viewCtrl:ViewController ) {
|
constructor(private _fb:FormBuilder,public navCtrl: NavController, public navParams: NavParams,public actionSheetCtrl: ActionSheetController,private salesPDService:SalesPdProvider,private toastProvider:ToastProvider,private loaderProvider:LoadingProvider,private viewCtrl:ViewController ) {
|
||||||
this.todaydate = new Date();
|
this.todaydate = new Date();
|
||||||
this.getDropdown();
|
this.getDropdown();
|
||||||
@ -42,7 +43,8 @@ export class AdvanceFilterPage {
|
|||||||
let local:any = JSON.parse(localStorage.getItem('user_details'));
|
let local:any = JSON.parse(localStorage.getItem('user_details'));
|
||||||
console.log('local****',local);
|
console.log('local****',local);
|
||||||
this.drop_down_datas = this.navParams.get('drop_down_datas');
|
this.drop_down_datas = this.navParams.get('drop_down_datas');
|
||||||
this.setDropDownDatas()
|
this.is_sales_login = this.navParams.get('is_sales_login')
|
||||||
|
// this.setDropDownDatas()
|
||||||
console.log(this.drop_down_datas);
|
console.log(this.drop_down_datas);
|
||||||
this.searchForm=this._fb.group({
|
this.searchForm=this._fb.group({
|
||||||
pd_status:[''],
|
pd_status:[''],
|
||||||
@ -52,30 +54,30 @@ export class AdvanceFilterPage {
|
|||||||
pd_lender:[local.fk_entity_id],
|
pd_lender:[local.fk_entity_id],
|
||||||
pd_applicant_name:[''],
|
pd_applicant_name:[''],
|
||||||
pd_officer:[''],
|
pd_officer:[''],
|
||||||
sales_pd_officer_id:[local.userid]
|
sales_pd_officer_id:[this.is_sales_login ? local.userid : '']
|
||||||
})
|
})
|
||||||
console.log(this.drop_down_datas)
|
console.log(this.drop_down_datas)
|
||||||
}
|
}
|
||||||
getDropdown(){
|
getDropdown(){
|
||||||
// this.salesPDService.getAllMasterDatas('PDSTATUS').subscribe(res=>
|
this.salesPDService.getAllMasterDatas('PDSTATUS').subscribe(res=>
|
||||||
// {
|
{
|
||||||
// if(res.dataStatus==true)
|
if(res.dataStatus==true)
|
||||||
// {
|
{
|
||||||
// this.pdStatus_all = res.records.filter(status=>status.isactive==1);
|
this.pdStatus = res.records.filter(status=>status.isactive==1 && status.hasOwnProperty('avail_pd_types') && (status.avail_pd_types == '2' || status.avail_pd_types == '3' ))
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
this.salesPDService.getAllMasterDatas('ENTITY').subscribe(res=>
|
this.salesPDService.getAllMasterDatas('ENTITY').subscribe(res=>
|
||||||
{
|
{
|
||||||
if(res.dataStatus==true)
|
if(res.dataStatus==true)
|
||||||
{
|
{
|
||||||
this.ENTITY = res.records.filter(ent=>ent.isactive==1);
|
this.ENTITY = res.records.filter(ent=>ent.isactive==1 && ent.hasOwnProperty('avail_pd_types') && (ent.avail_pd_types == '2' || ent.avail_pd_types == '3' ));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.salesPDService.getAllMasterDatas('PRODUCTS').subscribe(res=>
|
this.salesPDService.getAllMasterDatas('PRODUCTS').subscribe(res=>
|
||||||
{
|
{
|
||||||
if(res.dataStatus==true)
|
if(res.dataStatus==true)
|
||||||
{
|
{
|
||||||
this.PRODUCTS = res.records.filter(pro=>pro.isactive==1);
|
this.PRODUCTS = res.records.filter(pro=>pro.isactive==1 && pro.hasOwnProperty('avail_pd_types') && (pro.avail_pd_types == '2' || pro.avail_pd_types == '3' ));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -122,7 +124,16 @@ export class AdvanceFilterPage {
|
|||||||
console.log(res);
|
console.log(res);
|
||||||
// this.filteredlistData.emit(res);
|
// this.filteredlistData.emit(res);
|
||||||
// this.xpandStatus=false
|
// this.xpandStatus=false
|
||||||
this.viewCtrl.dismiss(res['records'])
|
let listValue = res['records']
|
||||||
|
if(listValue && listValue.length > 0) {
|
||||||
|
if(!this.is_sales_login) {
|
||||||
|
listValue = listValue.filter(vvd=>vvd.status == 'COMPLETED')
|
||||||
|
}
|
||||||
|
this.viewCtrl.dismiss(listValue)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.toastProvider.lenderappmessage('No Records Found...!')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// this.filteredlistData.emit(res)
|
// this.filteredlistData.emit(res)
|
||||||
|
|||||||
@ -88,7 +88,7 @@
|
|||||||
</mat-card>
|
</mat-card>
|
||||||
</ion-grid>
|
</ion-grid>
|
||||||
</ion-list>
|
</ion-list>
|
||||||
<ion-fab right bottom (click)="newForm()">
|
<ion-fab right bottom (click)="newForm()" *ngIf="is_sales_login">
|
||||||
<button ion-fab mini color="optblue"><ion-icon color="light" name="md-add"></ion-icon></button>
|
<button ion-fab mini color="optblue"><ion-icon color="light" name="md-add"></ion-icon></button>
|
||||||
</ion-fab>
|
</ion-fab>
|
||||||
<!-- <ion-footer>
|
<!-- <ion-footer>
|
||||||
|
|||||||
@ -10,6 +10,11 @@ import { AdvanceFilterPage } from '../advance-filter/advance-filter';
|
|||||||
import { OfflineManagerProvider } from '../../providers/offline-manager/offline-manager';
|
import { OfflineManagerProvider } from '../../providers/offline-manager/offline-manager';
|
||||||
import { IonicStorageProvider } from '../../../../providers/ionic-storage/ionic-storage';
|
import { IonicStorageProvider } from '../../../../providers/ionic-storage/ionic-storage';
|
||||||
import { CameraProvider } from '../../providers/camera/camera';
|
import { CameraProvider } from '../../providers/camera/camera';
|
||||||
|
import { ConstantsProvider } from '../../../../providers/constants/constants';
|
||||||
|
import { SectionListPageModule } from '../section-list/section-list.module';
|
||||||
|
import { CreditSectionListPageModule } from '../../../credit_pd/pages/credit-section-list/credit-section-list.module';
|
||||||
|
import { CreditSectionListPage } from '../../../credit_pd/pages/credit-section-list/credit-section-list';
|
||||||
|
import { ApiServiceProvider } from '../../../credit_pd/providers/api-service/api-service';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,9 +37,17 @@ export class SalesPDlistPage {
|
|||||||
filterMsg: boolean = false;
|
filterMsg: boolean = false;
|
||||||
common: any;
|
common: any;
|
||||||
localPDs:any =[ ]
|
localPDs:any =[ ]
|
||||||
|
is_sales_login:boolean = false
|
||||||
constructor(public actionSheetCtrl: ActionSheetController,public navCtrl: NavController, public navParams: NavParams,private salesPDService:SalesPdProvider,private toastProvider:ToastProvider,private loaderProvider:LoadingProvider,private modalCtrl:ModalController,private offlineManager:OfflineManagerProvider,
|
constructor(public actionSheetCtrl: ActionSheetController,public navCtrl: NavController, public navParams: NavParams,private salesPDService:SalesPdProvider,private toastProvider:ToastProvider,private loaderProvider:LoadingProvider,private modalCtrl:ModalController,private offlineManager:OfflineManagerProvider,
|
||||||
private ionicStorageService:IonicStorageProvider,private cameraProvider:CameraProvider) {
|
private ionicStorageService:IonicStorageProvider,private cameraProvider:CameraProvider,private constantProvider:ConstantsProvider,private _creditPdService:ApiServiceProvider) {
|
||||||
|
let userDetails = localStorage.getItem('user_details');
|
||||||
|
let role= this.constantProvider.takeDecisionRouting(JSON.parse(userDetails))
|
||||||
|
if(role == 'sales'){
|
||||||
|
this.is_sales_login = true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.is_sales_login = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ionViewDidLoad() {
|
ionViewDidLoad() {
|
||||||
@ -77,7 +90,7 @@ export class SalesPDlistPage {
|
|||||||
getListofPD(){
|
getListofPD(){
|
||||||
return this.ionicStorageService.getLocalDataWithFilter(pd_key,{name:'sales_pd_id',type:'filter',value:null}).then(local_res=>{
|
return this.ionicStorageService.getLocalDataWithFilter(pd_key,{name:'sales_pd_id',type:'filter',value:null}).then(local_res=>{
|
||||||
console.log(local_res);
|
console.log(local_res);
|
||||||
this.salesPDService.getSalesPDList().subscribe(res=>{
|
this.salesPDService.getSalesPDList(this.is_sales_login).subscribe(res=>{
|
||||||
if(res['dataStatus']){
|
if(res['dataStatus']){
|
||||||
this.sales_displayValue=res['records']
|
this.sales_displayValue=res['records']
|
||||||
if(local_res && local_res.length > 0) {
|
if(local_res && local_res.length > 0) {
|
||||||
@ -97,6 +110,9 @@ export class SalesPDlistPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(this.sales_displayValue.length > 0){
|
if(this.sales_displayValue.length > 0){
|
||||||
|
if(!this.is_sales_login) {
|
||||||
|
this.sales_displayValue = this.sales_displayValue.filter(vll=>vll.status == 'COMPLETED');
|
||||||
|
}
|
||||||
this.filterMsg = true
|
this.filterMsg = true
|
||||||
let products=[]
|
let products=[]
|
||||||
let lenders=[]
|
let lenders=[]
|
||||||
@ -227,7 +243,7 @@ export class SalesPDlistPage {
|
|||||||
const modalOption:ModalOptions={
|
const modalOption:ModalOptions={
|
||||||
cssClass:'filterModal'
|
cssClass:'filterModal'
|
||||||
}
|
}
|
||||||
const modalCtrl=this.modalCtrl.create(AdvanceFilterPage,{'drop_down_datas':this.filter_drop_down_data},modalOption)
|
const modalCtrl=this.modalCtrl.create(AdvanceFilterPage,{'drop_down_datas':this.filter_drop_down_data,is_sales_login:this.is_sales_login},modalOption)
|
||||||
modalCtrl.present();
|
modalCtrl.present();
|
||||||
modalCtrl.onDidDismiss((data)=>{
|
modalCtrl.onDidDismiss((data)=>{
|
||||||
console.log(data)
|
console.log(data)
|
||||||
@ -239,6 +255,7 @@ export class SalesPDlistPage {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
presentActionSheet(value_obj) {
|
presentActionSheet(value_obj) {
|
||||||
|
// if(this.is_sales_login) {
|
||||||
let actionSheet = this.actionSheetCtrl.create({
|
let actionSheet = this.actionSheetCtrl.create({
|
||||||
title: 'Select Option',
|
title: 'Select Option',
|
||||||
buttons: [
|
buttons: [
|
||||||
@ -263,5 +280,72 @@ export class SalesPDlistPage {
|
|||||||
});
|
});
|
||||||
|
|
||||||
actionSheet.present();
|
actionSheet.present();
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// let actionSheet = this.actionSheetCtrl.create({
|
||||||
|
// title: 'Select Option',
|
||||||
|
// buttons: [
|
||||||
|
// {
|
||||||
|
// text: 'Trigger Credit PD',
|
||||||
|
// icon:'add',
|
||||||
|
// role: 'credit',
|
||||||
|
// handler: () => {
|
||||||
|
// // this.salesPDpdf(value_obj.sales_pd_id);
|
||||||
|
// this.triggerCreditPdFun(value_obj)
|
||||||
|
// console.log('pdf check',this.salesPDpdf);
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// text: 'View Report',
|
||||||
|
// icon:'eye',
|
||||||
|
// role: 'destructive',
|
||||||
|
// handler: () => {
|
||||||
|
// this.salesPDpdf(value_obj.sales_pd_id);
|
||||||
|
// // console.log('pdf check',this.salesPDpdf);
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// text: 'Cancel',
|
||||||
|
// role: 'cancel',
|
||||||
|
// icon:'arrow-round-back',
|
||||||
|
// handler: () => {
|
||||||
|
// console.log('Cancel clicked');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// });
|
||||||
|
|
||||||
|
// actionSheet.present();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
triggerCreditPdFun(curr_list_obj:any) {
|
||||||
|
let message = 'Please Confirm you are triggering credit PD for the company <strong>'+curr_list_obj.applicant_name+'('+curr_list_obj.abbr+`)</strong><br/><br/>
|
||||||
|
<strong>Choose the PD Type :</strong>`
|
||||||
|
let pd_type_list:any=[{
|
||||||
|
id:"1",
|
||||||
|
dis_name:"Physical PD"
|
||||||
|
},{
|
||||||
|
id:"2",
|
||||||
|
dis_name:"Telephonic PD"
|
||||||
|
}]
|
||||||
|
let alert = this.toastProvider.setAlertWithRadioButtons("Confirm ?",message,{button1:"Cancel",button2:'Yes'},pd_type_list)
|
||||||
|
alert.present();
|
||||||
|
alert.onDidDismiss((data)=>{
|
||||||
|
console.log(data);
|
||||||
|
if(data != false) {
|
||||||
|
let new_credit_pd_info = curr_list_obj
|
||||||
|
// {fk_sales_pd_id:curr_list_obj.sales_pd_id,sales_pd_sno:curr_list_obj.sales_pd_sno,product_id:curr_list_obj.product_id,smc_credit_pd_type:result,smc_credit_pd:null,lender_id:curr_list_obj.lender_id,applicant_name:curr_list_obj.applicant_name,}
|
||||||
|
new_credit_pd_info.fk_sales_pd_id = curr_list_obj.sales_pd_id
|
||||||
|
new_credit_pd_info.smc_credit_pd_type = data
|
||||||
|
new_credit_pd_info.smc_credit_pd = null
|
||||||
|
this._creditPdService.curr_credit_pd_data = new_credit_pd_info
|
||||||
|
// this._creditPdService.curr_credit_pd_data = new_credit_pd_info
|
||||||
|
// this.router.navigate(['../credit_pd/pdQuestions'])
|
||||||
|
this.navCtrl.setRoot(CreditSectionListPage,{product_id:curr_list_obj.product_id,sales_pd_type:data})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { FormGroup, FormControl, FormArray, FormBuilder, Validators } from '@angular/forms';
|
import { FormGroup, FormControl, FormArray, FormBuilder, Validators } from '@angular/forms';
|
||||||
import { SalesPdProvider } from '../sales-pd/sales-pd';
|
import { SalesPdProvider } from '../sales-pd/sales-pd';
|
||||||
import { DatePipe } from '@angular/common';
|
import { DatePipe } from '@angular/common';
|
||||||
|
import { ApiServiceProvider } from '../../../credit_pd/providers/api-service/api-service';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Generated class for the QuesServiceProvider provider.
|
Generated class for the QuesServiceProvider provider.
|
||||||
@ -13,13 +14,15 @@ import { DatePipe } from '@angular/common';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class QuesServiceProvider {
|
export class QuesServiceProvider {
|
||||||
datepipe: DatePipe;
|
datepipe: DatePipe;
|
||||||
|
curr_pd_info: any;
|
||||||
|
|
||||||
constructor(public http: HttpClient,private _fb:FormBuilder,private salesPDProvider:SalesPdProvider) {
|
constructor(public http: HttpClient,private _fb:FormBuilder,private salesPDProvider:SalesPdProvider,private apiService:ApiServiceProvider) {
|
||||||
console.log('Hello QuesServiceProvider Provider');
|
console.log('Hello QuesServiceProvider Provider');
|
||||||
this.datepipe=new DatePipe('en-US')
|
this.datepipe=new DatePipe('en-US')
|
||||||
}
|
}
|
||||||
// FOR CREATING A FORM CONTROL DYNAMICALLY
|
// FOR CREATING A FORM CONTROL DYNAMICALLY
|
||||||
assignFormControl_array(formgroup: FormGroup, ques_data: any) {
|
assignFormControl_array(formgroup: FormGroup, ques_data: any) {
|
||||||
|
this.curr_pd_info = this.apiService.curr_credit_pd_data
|
||||||
console.log(formgroup, ques_data)
|
console.log(formgroup, ques_data)
|
||||||
const control: any = formgroup.get('questions') as FormArray
|
const control: any = formgroup.get('questions') as FormArray
|
||||||
ques_data.forEach((val, index) => {
|
ques_data.forEach((val, index) => {
|
||||||
@ -27,8 +30,9 @@ export class QuesServiceProvider {
|
|||||||
if (val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') {
|
if (val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') {
|
||||||
control.push(this._fb.group({
|
control.push(this._fb.group({
|
||||||
"is_repeatable": [val.is_repeatable || null],
|
"is_repeatable": [val.is_repeatable || null],
|
||||||
|
"is_multi_disabled":[val.is_multi_disabled || '0'],
|
||||||
"group_title": [val.group_title || null], "group_type": [val.group_type || null]
|
"group_title": [val.group_title || null], "group_type": [val.group_type || null]
|
||||||
,"question_key":[val.question[0].question_key]
|
,"question_key":[val.question && val.question.length > 0 ? val.question[0].question_key : val.question_key]
|
||||||
}))
|
}))
|
||||||
// let temp=val
|
// let temp=val
|
||||||
|
|
||||||
@ -184,7 +188,15 @@ export class QuesServiceProvider {
|
|||||||
apiPropertiesCall(val){
|
apiPropertiesCall(val){
|
||||||
return new Promise((resolve,reject)=>{
|
return new Promise((resolve,reject)=>{
|
||||||
if(val.api_properties != null && typeof(val.api_properties) == 'object'){
|
if(val.api_properties != null && typeof(val.api_properties) == 'object'){
|
||||||
this.salesPDProvider.api_post_method(val.api_properties.api,val.api_properties.params,val.api_properties.api_method).subscribe(res=>{
|
let pd_info = this.curr_pd_info
|
||||||
|
console.log(pd_info)
|
||||||
|
let params = val.api_properties.params
|
||||||
|
if(val.api_properties.hasOwnProperty('params_type') && val.api_properties.params_type == 'expression') {
|
||||||
|
params = eval(val.api_properties.params)
|
||||||
|
console.log(params,this.curr_pd_info.smc_credit_pd)
|
||||||
|
// debugger;
|
||||||
|
}
|
||||||
|
this.salesPDProvider.api_post_method(val.api_properties.api,params,val.api_properties.api_method).subscribe(res=>{
|
||||||
if(res['dataStatus']){
|
if(res['dataStatus']){
|
||||||
if(res.hasOwnProperty('records')){
|
if(res.hasOwnProperty('records')){
|
||||||
res=res['records']
|
res=res['records']
|
||||||
@ -210,11 +222,19 @@ export class QuesServiceProvider {
|
|||||||
let val1=[]
|
let val1=[]
|
||||||
let modified_json = data_from_api.map(
|
let modified_json = data_from_api.map(
|
||||||
obj => {
|
obj => {
|
||||||
|
if(fieldName.length > 0) {
|
||||||
return {
|
return {
|
||||||
"answer_id" : obj[fieldName[0]],
|
"answer_id" : obj[fieldName[0]],
|
||||||
"answer":obj[fieldName[1]],
|
"answer":obj[fieldName[1]],
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return {
|
||||||
|
"answer_id" : obj,
|
||||||
|
"answer":obj,
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return modified_json
|
return modified_json
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import { NetworkDetectionProvider, ConnectionStatus } from '../../../../provider
|
|||||||
import { IonicStorageProvider } from '../../../../providers/ionic-storage/ionic-storage';
|
import { IonicStorageProvider } from '../../../../providers/ionic-storage/ionic-storage';
|
||||||
import { OfflineManagerProvider } from '../offline-manager/offline-manager';
|
import { OfflineManagerProvider } from '../offline-manager/offline-manager';
|
||||||
import { PdtriggerProvider } from '../../../../providers/pdtrigger/pdtrigger';
|
import { PdtriggerProvider } from '../../../../providers/pdtrigger/pdtrigger';
|
||||||
|
import { ApiServiceProvider } from '../../../credit_pd/providers/api-service/api-service';
|
||||||
// import {environment} from '../../../../providers/constants/constants'
|
// import {environment} from '../../../../providers/constants/constants'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -27,7 +28,7 @@ available_sections:any;
|
|||||||
original_rawData:any;
|
original_rawData:any;
|
||||||
current_section:any;
|
current_section:any;
|
||||||
constructor(public http: HttpClient,private constantProvider:ConstantsProvider,private storage:Storage,private aws:AwsServiceProvider,private cameraService:CameraProvider,
|
constructor(public http: HttpClient,private constantProvider:ConstantsProvider,private storage:Storage,private aws:AwsServiceProvider,private cameraService:CameraProvider,
|
||||||
private networkProvider:NetworkDetectionProvider,private ionicStorageProvider:IonicStorageProvider,private offlineManagerProvider:OfflineManagerProvider) {
|
private networkProvider:NetworkDetectionProvider,private ionicStorageProvider:IonicStorageProvider,private offlineManagerProvider:OfflineManagerProvider,private creditPDService:ApiServiceProvider) {
|
||||||
console.log('Hello SalesPdProvider Provider');
|
console.log('Hello SalesPdProvider Provider');
|
||||||
this.apiUrl=this.constantProvider.environment().url
|
this.apiUrl=this.constantProvider.environment().url
|
||||||
}
|
}
|
||||||
@ -377,19 +378,53 @@ current_section:any;
|
|||||||
|
|
||||||
api_post_method(api_name:string,params,api_method?){
|
api_post_method(api_name:string,params,api_method?){
|
||||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||||
|
return Observable.create((observer:Observer<any>)=>{
|
||||||
if(api_method.toUpperCase() == 'POST'){
|
if(api_method.toUpperCase() == 'POST'){
|
||||||
return this.http.post(this.apiUrl+api_name,params).map(result=> {
|
return this.http.post(this.apiUrl+api_name,params).subscribe(result=> {
|
||||||
this.ionicStorageProvider.checkAndInsertApiDataLocally(result,params,api_name,true);
|
if(result['dataStatus']) {
|
||||||
return result
|
return this.ionicStorageProvider.checkAndInsertApiDataLocally(result,params,api_name,true).then(r=>{
|
||||||
|
observer.next(result);
|
||||||
|
observer.complete()
|
||||||
|
},err=>console.log("ionnic storage err",err));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
observer.next(result);
|
||||||
|
observer.complete()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return this.http.get(this.apiUrl+api_name).map(result=> {
|
return this.http.get(this.apiUrl+api_name).pipe().subscribe(result=> {
|
||||||
this.ionicStorageProvider.checkAndInsertApiDataLocally(result,params,api_name);
|
return this.ionicStorageProvider.checkAndInsertApiDataLocally(result,params,api_name).then(rr=>{
|
||||||
return result
|
observer.next(result);
|
||||||
|
observer.complete()
|
||||||
|
},err=>console.log("ionnic storage err",err));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
// FOR CREDIT PD STACKHOLDER INFO API
|
||||||
|
else if (api_name == 'getStakeHoldersInfo'){
|
||||||
|
return this.creditPDService.getStakeholderInfo().map(res=>{
|
||||||
|
console.log(res);
|
||||||
|
if(res['dataStatus']) {
|
||||||
|
let section_data = res['records'][0].section_data
|
||||||
|
section_data = JSON.parse(section_data);
|
||||||
|
let stakeholder_ques = section_data.questions.filter(vv=>vv.is_repeatable == '1')[0]
|
||||||
|
console.log(stakeholder_ques);
|
||||||
|
|
||||||
|
if(stakeholder_ques.hasOwnProperty('questions_group') && stakeholder_ques.questions_group.length > 0) {
|
||||||
|
let applicants = stakeholder_ques.questions_group.map(vv=>vv.questions[0].answer_value)
|
||||||
|
console.log(applicants);
|
||||||
|
// debugger;
|
||||||
|
return {dataStatus:true,records:applicants}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// debugger;
|
||||||
|
return res
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return this.ionicStorageProvider.getApiDataFromLocally(params,api_name)
|
return this.ionicStorageProvider.getApiDataFromLocally(params,api_name)
|
||||||
}
|
}
|
||||||
@ -464,7 +499,7 @@ current_section:any;
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
getSalesPDList(){
|
getSalesPDList(is_sales_login){
|
||||||
// let params = new HttpParams().set("paramName",paramValue)
|
// let params = new HttpParams().set("paramName",paramValue)
|
||||||
|
|
||||||
// console.log("Api Stauts ",this.networkProvider.getCurrentNetworkStatus())
|
// console.log("Api Stauts ",this.networkProvider.getCurrentNetworkStatus())
|
||||||
@ -472,7 +507,11 @@ current_section:any;
|
|||||||
det=JSON.parse(det)
|
det=JSON.parse(det)
|
||||||
let params = {'fk_entity_id':det.fk_entity_id,userid:det.userid}
|
let params = {'fk_entity_id':det.fk_entity_id,userid:det.userid}
|
||||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||||
return this.http.get(this.apiUrl+'listSalesPD/'+det.fk_entity_id+'/'+det.userid).map(res=>{
|
let complete_url = this.apiUrl+'listSalesPD/'+det.fk_entity_id
|
||||||
|
if(is_sales_login) {
|
||||||
|
complete_url = complete_url+'/'+det.userid
|
||||||
|
}
|
||||||
|
return this.http.get(complete_url).map(res=>{
|
||||||
this.ionicStorageProvider.checkAndInsertApiDataLocally(res,params,'listSalesPD');
|
this.ionicStorageProvider.checkAndInsertApiDataLocally(res,params,'listSalesPD');
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
|
|||||||
@ -82,4 +82,52 @@ export class ToastProvider {
|
|||||||
//alert.present()
|
//alert.present()
|
||||||
return alert
|
return alert
|
||||||
}
|
}
|
||||||
|
setAlertWithRadioButtons(title,msg,buttons,radioValues) {
|
||||||
|
let alert = this.alertCtrl.create({
|
||||||
|
title:title,
|
||||||
|
cssClass:'buttoncss',
|
||||||
|
message:msg,
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
type: 'radio',
|
||||||
|
label: radioValues[0].dis_name,
|
||||||
|
value: radioValues[0].id
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'radio',
|
||||||
|
label: radioValues[1].dis_name,
|
||||||
|
value: radioValues[1].id
|
||||||
|
}
|
||||||
|
],
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
text:buttons.button1,
|
||||||
|
role: 'cancel',
|
||||||
|
cssClass:'btnNo',
|
||||||
|
handler: () => {
|
||||||
|
console.log('Cancel clicked');
|
||||||
|
alert.dismiss(false)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text:buttons.button2,
|
||||||
|
cssClass:'btnYes',
|
||||||
|
handler: (data) => {
|
||||||
|
console.log('OK clicked: ',data );
|
||||||
|
if(data != undefined) {
|
||||||
|
alert.dismiss(data)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.lenderappmessage("Please choose the PD Type")
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
// I NEED TO GET THE VALUE OF THE SELECTED RADIO BUTTON HERE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
// alert.present();
|
||||||
|
return alert
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,8 +41,13 @@ export class ConstantsProvider {
|
|||||||
authorization:'sparqvenba2018',
|
authorization:'sparqvenba2018',
|
||||||
|
|
||||||
lenIdentityPoolId:"ap-south-1:ca22dabc-db59-4af5-9bb8-265f7ec95907",
|
lenIdentityPoolId:"ap-south-1:ca22dabc-db59-4af5-9bb8-265f7ec95907",
|
||||||
lenUserPoolId: "ap-south-1_hFiGyr1Gw", // Username
|
|
||||||
lenClientId: "38v9rpp1495v60e1gd14mj6rjr", // ClientId for mobile
|
/** OLD ONE */
|
||||||
|
// lenUserPoolId: "ap-south-1_hFiGyr1Gw", // Username
|
||||||
|
// lenClientId: "38v9rpp1495v60e1gd14mj6rjr", // ClientId for mobile
|
||||||
|
|
||||||
|
lenUserPoolId: "ap-south-1_4kkhgsYo0", // Username
|
||||||
|
lenClientId: "57t9fv113b5eab5pra127bbgn0", // ClientId for mobile
|
||||||
}
|
}
|
||||||
|
|
||||||
let testing={
|
let testing={
|
||||||
@ -51,8 +56,13 @@ export class ConstantsProvider {
|
|||||||
authorization:'sparqvenba2018',
|
authorization:'sparqvenba2018',
|
||||||
|
|
||||||
lenIdentityPoolId:"ap-south-1:ca22dabc-db59-4af5-9bb8-265f7ec95907",
|
lenIdentityPoolId:"ap-south-1:ca22dabc-db59-4af5-9bb8-265f7ec95907",
|
||||||
lenUserPoolId: "ap-south-1_hFiGyr1Gw", // Username
|
|
||||||
lenClientId: "38v9rpp1495v60e1gd14mj6rjr", // ClientName for Mobile
|
/** OLD ONE */
|
||||||
|
// lenUserPoolId: "ap-south-1_hFiGyr1Gw", // Username
|
||||||
|
// lenClientId: "38v9rpp1495v60e1gd14mj6rjr", // ClientId for mobile
|
||||||
|
|
||||||
|
lenUserPoolId: "ap-south-1_4kkhgsYo0", // Username
|
||||||
|
lenClientId: "57t9fv113b5eab5pra127bbgn0", // ClientId for mobile
|
||||||
}
|
}
|
||||||
return testing;
|
return testing;
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,9 @@ export class IonicStorageProvider {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return this.ionicStorage.set(key,[value]);
|
return this.ionicStorage.set(key,[value]).then(e=>{
|
||||||
|
return e
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user