supplier and client : ps

This commit is contained in:
venbatechnologies@gmail.com 2019-07-11 20:14:07 +05:30
parent 01a9dbff57
commit 8cb9eaf845
5 changed files with 624 additions and 550 deletions

View File

@ -17,6 +17,18 @@
<mat-tab label="Questions">
<ng-template matTabContent>
<mat-card>
<mat-form-field style="width:60% !important;">
<mat-select placeholder="Is the Client Infomation Available" formControlName="client_info_available">
<mat-option>Select</mat-option>
<mat-option value="Yes">Yes</mat-option>
<mat-option value="No">No</mat-option>
</mat-select>
</mat-form-field>
</mat-card>
<!-- <mat-card *ngIf="currentLoanForm.controls.existing_loan.value == 'Yes'"> -->
<div *ngIf="_supplierQuesFrom.controls.client_info_available.value == 'Yes'">
<mat-card *ngIf="manufacturingForm">
<h5 style="margin: 12px;padding:10px !important;">Manufacturing Product Details</h5>
<div formArrayName="manufacturing_details">
@ -428,6 +440,17 @@
</div>
</div>
</mat-card>
<mat-card *ngIf="_supplierQuesFrom.controls.client_info_available.value == 'Yes'">
<mat-form-field style="width:60% !important;">
<mat-select placeholder="Is the Billing Infomation Available" formControlName="bill_info">
<mat-option>Select</mat-option>
<mat-option value="Yes">Yes</mat-option>
<mat-option value="No">No</mat-option>
</mat-select>
</mat-form-field>
</mat-card>
</div>
<!-- <mat-card *ngIf="retaildTradingForm">
<h5 style="margin: 12px;padding:10px !important;">Retail Trading Product Details</h5>
<div style="text-align: center; margin: 12px;">Retail Trading Details Not applicable here !!</div>
@ -494,7 +517,7 @@
<div fxFlex="60" class="pb-0 text-sm-left" align="left">
<mat-form-field appearance="outline" style="width: 100%">
<mat-label>Remarks</mat-label>
<textarea matInput placeholder="Remarks" formControlName="supplier_info_form_remark"></textarea>
<textarea matInput placeholder="Remarks" formControlName="supplier_info_form_remark" required></textarea>
</mat-form-field>
</div>
<div fxFlex="40" align="end">

View File

@ -207,6 +207,8 @@ export class ClientInfoComponent implements OnInit {
pdid: [this.pdid],
formid: ['2'],
company_id: [this.company_id],
client_info_available: [dataForm.client_info_available == true ? 'Yes' : 'No' || null],
bill_info: [dataForm.bill_info == true ? 'Yes' : 'No' || null],
manufacturing_details: this._formBuilder.array([this.manufacturingFormCreation(record)]),
trade_details: this._formBuilder.array([this.tradingFormCreation(record)]),
service_provider_details: this._formBuilder.array([this.serviceProviderFormCreation(record)]),
@ -279,6 +281,8 @@ export class ClientInfoComponent implements OnInit {
pdid: [this.pdid],
formid: ['2'],
company_id: [this.company_id],
client_info_available: [dataForm.client_info_available == true ? 'Yes' : 'No' || null],
bill_info: [dataForm.bill_info == true ? 'Yes' : 'No' || null],
manufacturing_details: this._formBuilder.array([this.manufacturingFormCreation(record)]),
trade_details: this._formBuilder.array([this.tradingFormCreation(record)]),
service_provider_details: this._formBuilder.array([this.serviceProviderFormCreation(record)]),
@ -316,6 +320,8 @@ export class ClientInfoComponent implements OnInit {
pdid: [this.pdid],
formid: ['2'],
company_id: [this.company_id],
client_info_available: [null],
bill_info: [null],
manufacturing_details: this._formBuilder.array([this.manufacturingFormCreation(record)]),
trade_details: this._formBuilder.array([this.tradingFormCreation(record)]),
service_provider_details: this._formBuilder.array([this.serviceProviderFormCreation(record)]),
@ -350,7 +356,6 @@ export class ClientInfoComponent implements OnInit {
);
}
manufacturingForm: Boolean = false;
manufacturingFormCreation(val) {
let arr = val.filter(data => data.type_of_activity_id == 2);
@ -366,6 +371,7 @@ export class ClientInfoComponent implements OnInit {
}
}
tradingForm: Boolean = false;
tradingFormCreation(val) {
// let arr = val.filter(data => data.type_of_activity_id == 4);
@ -641,6 +647,10 @@ export class ClientInfoComponent implements OnInit {
/** To Save/Edited Popup Data */
onSubmit() {
this.submitted = true;
this._supplierQuesFrom.value.client_info_available == 'No' ? this._supplierQuesFrom.controls['supplier_info_form_remark'].setValidators([Validators.required]) : this._supplierQuesFrom.controls['supplier_info_form_remark'].clearValidators();
this._supplierQuesFrom.controls['supplier_info_form_remark'].updateValueAndValidity();
// stop here if form is invalid
if (this._supplierQuesFrom.invalid) {
this.notifier.notify('warning', 'Please Check All Mandatory Fields.!');
@ -648,6 +658,9 @@ export class ClientInfoComponent implements OnInit {
} else {
var answerFormValues = this._supplierQuesFrom.value;
this._supplierQuesFrom.value.client_info_available == 'Yes' ? answerFormValues.client_info_available = true : answerFormValues.client_info_available = false ;
this._supplierQuesFrom.value.bill_info == 'Yes' ? answerFormValues.bill_info = true: answerFormValues.bill_info = false ;
//To Remove The "Null" With Key also
Object.keys(answerFormValues).forEach((key) => { if (answerFormValues[key] === null || answerFormValues[key] === undefined || answerFormValues[key] === '') { delete answerFormValues[key] }; });
if (answerFormValues.manufacturing_details[0] == null) {

View File

@ -1,11 +1,11 @@
/** Common Imports */
import { Component,OnInit,Inject,Output, Input } from '@angular/core';
import { Component, OnInit, Inject, Output, Input } from '@angular/core';
import { FormBuilder,FormGroup,Validators,FormArray } from '@angular/forms';
import { FormBuilder, FormGroup, Validators, FormArray } from '@angular/forms';
import { NotifierService } from 'angular-notifier';
import { MatDialog,MatDialogRef,MAT_DIALOG_DATA } from '@angular/material';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
/** Service */
import { PdTrigerService } from '../../../../../pd-service/pd-triger.service';
@ -61,9 +61,9 @@ export class SupplierInfoComponent implements OnInit {
this.customer_segment_abbr = this.pd_all_details.pdmaster_details.customer_segment_abbr;
}
pdf(fileURL){
pdf(fileURL) {
window.open(fileURL);
}
}
public viewerOptions: any = {
navbar: false,
toolbar: {
@ -111,11 +111,11 @@ export class SupplierInfoComponent implements OnInit {
let datas = data.records;
this.initFormLoadDetails(datas.type_of_activity);
this.m_manufacturingProducts = datas.type_of_activity.filter(data => { if (data.type_of_activity_id == 2) { return data } }).map(data => [...data.prodcuts]);
let api = Object.keys(datas.type_of_activity).map(function (key) {
return datas.type_of_activity[key];
});
if (api.length > 0) {
api.forEach(val => {
if (val.type_of_activity_id == 3) {
@ -129,7 +129,7 @@ export class SupplierInfoComponent implements OnInit {
this.m_tradingProducts.push(val.prodcuts);
}
}
if(val.type_of_activity_id == 5){
if (val.type_of_activity_id == 5) {
if (val.prodcuts) {
this.m_serviceProvider.push(val.prodcuts);
}
@ -137,9 +137,9 @@ export class SupplierInfoComponent implements OnInit {
});
}
this.m_tradingProducts = [].concat.apply([], this.m_tradingProducts);
this.m_serviceProvider = [].concat.apply([], this.m_serviceProvider);
this.m_serviceProvider = [].concat.apply([], this.m_serviceProvider);
} else {
this.notifier.notify('warning', 'No Category Records Found.!');
this.noRecordsFound = false;
@ -157,7 +157,7 @@ export class SupplierInfoComponent implements OnInit {
this.getMasterDetails('COMPANYRELATIONSHIPS', 1);
this.getMasterDetails('TITLES', 2);
this.retriveFile();
}
}
initFormLoadDetails(record) {
let params: any = {};
@ -176,9 +176,11 @@ export class SupplierInfoComponent implements OnInit {
pdid: [this.pdid],
formid: ['1'],
company_id: [this.company_id],
supplier_info_available: [dataForm.supplier_info_available == true ? 'Yes' : 'No' || null],
manufacturing_details: this._formBuilder.array([this.manufacturingFormCreation(record)]),
trade_details: this._formBuilder.array([this.tradingFormCreation(record)]),
servicing_details: this._formBuilder.array([this.servicingFormCreation(record)]),
bill_info: [dataForm.bill_info == true ? 'Yes' : 'No' || null],
supplier_info_form_remark: [dataForm.supplier_info_form_remark || null]
// wholesale_trade_details: this._formBuilder.array([this.tradingFormCreation(record)]),
});
@ -200,7 +202,6 @@ export class SupplierInfoComponent implements OnInit {
}
let arr1 = record.filter(data => data.type_of_activity_id == 3 || data.type_of_activity_id == 4);
if (arr1.length > 0) {
if (dataForm.trade_details[0] !== null) {
// let api_trading_products = Object.keys(dataForm.trading_products).map(function (key) {
@ -217,9 +218,8 @@ export class SupplierInfoComponent implements OnInit {
}
let arr2 = record.filter(data => data.type_of_activity_id == 5);
if (arr2.length > 0) {
if (dataForm.hasOwnProperty('servicing_details') && dataForm.servicing_details[0] !== null) {
let api_service_providers = dataForm.servicing_details[0].service_providers;
this.initServiceProvidersDetails(api_service_providers);
@ -231,6 +231,8 @@ export class SupplierInfoComponent implements OnInit {
}
}
this.noRecordsFound = true;
} else {
this._supplierQuesFrom = this._formBuilder.group({
@ -238,9 +240,11 @@ export class SupplierInfoComponent implements OnInit {
pdid: [this.pdid],
formid: ['1'],
company_id: [this.company_id],
supplier_info_available: [dataForm.supplier_info_available == true ? 'Yes' : 'No' || null],
manufacturing_details: this._formBuilder.array([this.manufacturingFormCreation(record)]),
trade_details: this._formBuilder.array([this.tradingFormCreation(record)]),
servicing_details: this._formBuilder.array([this.servicingFormCreation(record)]),
bill_info: [dataForm.bill_info == true ? 'Yes' : 'No' || null],
supplier_info_form_remark: [dataForm.supplier_info_form_remark || null]
// wholesale_trade_details: this._formBuilder.array([this.tradingFormCreation(record)]),
});
@ -256,7 +260,7 @@ export class SupplierInfoComponent implements OnInit {
}
let arr2 = record.filter(data => data.type_of_activity_id == 5);
if (arr2.length > 0) {
this.initServiceProvidersDetails(null);
this._supplierQuesFrom.controls['servicing_details']['controls'][0].controls['service_providers_total_payments_percent_on_credit'].setValue(dataForm.servicing_details[0].service_providers_total_payments_percent_on_credit || null);
}
@ -268,9 +272,11 @@ export class SupplierInfoComponent implements OnInit {
pdid: [this.pdid],
formid: ['1'],
company_id: [this.company_id],
supplier_info_available: [null],
manufacturing_details: this._formBuilder.array([this.manufacturingFormCreation(record)]),
trade_details: this._formBuilder.array([this.tradingFormCreation(record)]),
servicing_details: this._formBuilder.array([this.servicingFormCreation(record)]),
bill_info: [null],
supplier_info_form_remark: []
// wholesale_trade_details: this._formBuilder.array([this.tradingFormCreation(record)]),
});
@ -299,6 +305,11 @@ export class SupplierInfoComponent implements OnInit {
}
// data.controls.locality.value == 5
// ? this.addressForm.controls['locality_mixuse'].setValidators([Validators.required])
// : this.addressForm.controls['locality_mixuse'].clearValidators();
// this.addressForm.controls['locality_mixuse'].updateValueAndValidity();
manufacturingForm: Boolean = false;
manufacturingFormCreation(val) {
let arr = val.filter(data => data.type_of_activity_id == 2);
@ -392,7 +403,7 @@ export class SupplierInfoComponent implements OnInit {
})
}
}
initTradingProductsDetails(datas) {
const control = <FormArray>this._supplierQuesFrom.controls['trade_details']['controls'][0].controls['trading_products'];
@ -449,7 +460,7 @@ export class SupplierInfoComponent implements OnInit {
if (datas === null) {
control.push(this.initServiceProviders(null));
} else {
datas.forEach((val, inx) => {
this.checkCard(val.service_provider_payment_type, 3, inx);
@ -519,7 +530,7 @@ export class SupplierInfoComponent implements OnInit {
const control = <FormArray>this._supplierQuesFrom.controls['trade_details']['controls'][0].controls['trading_products'];
control.removeAt(inx);
}
addMoreServiceProvider(e): void {
// e.stropPropagation();
const control = <FormArray>this._supplierQuesFrom.controls['servicing_details']['controls'][0].controls['service_providers'];
@ -583,13 +594,17 @@ export class SupplierInfoComponent implements OnInit {
onSubmit() {
this.submitted = true;
// stop here if form is invalid
this._supplierQuesFrom.value.supplier_info_available == 'No' ? this._supplierQuesFrom.controls['supplier_info_form_remark'].setValidators([Validators.required]) : this._supplierQuesFrom.controls['supplier_info_form_remark'].clearValidators();
this._supplierQuesFrom.controls['supplier_info_form_remark'].updateValueAndValidity();
if (this._supplierQuesFrom.invalid) {
this.notifier.notify('warning', 'Please Check All Mandatory Fields.!');
return;
} else {
var answerFormValues = this._supplierQuesFrom.value;
var answerFormValues = this._supplierQuesFrom.value;
this._supplierQuesFrom.value.supplier_info_available == 'Yes' ? answerFormValues.client_info_available = true : answerFormValues.client_info_available = false ;
this._supplierQuesFrom.value.bill_info == 'Yes' ? answerFormValues.bill_info = true: answerFormValues.bill_info = false ;
//To Remove The "Null" With Key also
Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]);
//Add BRANCH data with help Service File
@ -609,7 +624,7 @@ export class SupplierInfoComponent implements OnInit {
// this.errorMessage = "Some Thing Went Wrong Try Again !";
}
}, error => {
this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!');
this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') + '\" Error Occur.!');
// this.errorMessage = "Something Went Wrong Try Again !";
// this.dialogRef.close();
});
@ -625,18 +640,18 @@ export class SupplierInfoComponent implements OnInit {
selectedPersonDesignation(items, e, flag) {
if (flag == 1) {
if(e == 1){ items.controls['other_person_designation'].setValidators([Validators.required]); }
else { items.controls['other_person_designation'].clearValidators(); items.controls['other_person_designation'].setValue('');}
if (e == 1) { items.controls['other_person_designation'].setValidators([Validators.required]); }
else { items.controls['other_person_designation'].clearValidators(); items.controls['other_person_designation'].setValue(''); }
items.controls['other_person_designation'].updateValueAndValidity();
}
else if (flag == 2) {
if(e == 1){ items.controls['other_person_designation'].setValidators([Validators.required]); }
else{ items.controls['other_person_designation'].clearValidators(); items.controls['other_person_designation'].setValue('');}
if (e == 1) { items.controls['other_person_designation'].setValidators([Validators.required]); }
else { items.controls['other_person_designation'].clearValidators(); items.controls['other_person_designation'].setValue(''); }
items.controls['other_person_designation'].updateValueAndValidity();
}
else if (flag == 3) {
if(e == 1){ items.controls['other_person_designation'].setValidators([Validators.required]); }
else{ items.controls['other_person_designation'].clearValidators(); items.controls['other_person_designation'].setValue('');}
if (e == 1) { items.controls['other_person_designation'].setValidators([Validators.required]); }
else { items.controls['other_person_designation'].clearValidators(); items.controls['other_person_designation'].setValue(''); }
items.controls['other_person_designation'].updateValueAndValidity();
}
}
@ -708,7 +723,7 @@ export class SupplierInfoComponent implements OnInit {
}
else if (flag == 1) {
if (e == 3) {
items.controls['manufacturing_credit_days_from'].setValidators([Validators.required]);
items.controls['manufacturing_credit_days_from'].setValidators([Validators.required]);
items.controls['manufacturing_credit_days_to'].setValidators([Validators.required]);
}
else {
@ -736,41 +751,41 @@ export class SupplierInfoComponent implements OnInit {
// let arr = { 'pic_name':pic_name,'pic':pic,'from_id':this.form_id}
pic.pdid = this.pdid;
const imageRef = this.dialog.open(ImageCropComponent, {
data: pic,
maxWidth: '100vw',
maxHeight: '100vh',
height: '100%',
width: '100%',
data: pic,
maxWidth: '100vw',
maxHeight: '100vh',
height: '100%',
width: '100%',
});
imageRef.afterClosed()
.subscribe(dataresult => {
if(dataresult == 1){
this.documentsAndFilesList = [];
this.retriveFile();
}
});
}
retriveFile(){
this.pdTrigerService.retriveFile(this.pdid,this.form_id,this.company_id).subscribe(data => {
.subscribe(dataresult => {
if (dataresult == 1) {
this.documentsAndFilesList = [];
this.retriveFile();
}
});
}
retriveFile() {
this.pdTrigerService.retriveFile(this.pdid, this.form_id, this.company_id).subscribe(data => {
if (data.status == 200) {
if (data.records.length > 0) {
data.records.forEach((val, index) => {
let splitted = val.pd_document_name.split(".");
let DocumentsAndFiles = {
'document_id':val.pd_document_id,
'document_name': val.pd_document_name,
'document_title': val.pd_document_title,
'document': val.doc_url,
'document_type': splitted[1] == 'pdf' ? 'pdf' : 'image',
'is_show_report':val.is_show_report
}
this.documentsAndFilesList.push(DocumentsAndFiles);
});
}
if (data.records.length > 0) {
data.records.forEach((val, index) => {
let splitted = val.pd_document_name.split(".");
let DocumentsAndFiles = {
'document_id': val.pd_document_id,
'document_name': val.pd_document_name,
'document_title': val.pd_document_title,
'document': val.doc_url,
'document_type': splitted[1] == 'pdf' ? 'pdf' : 'image',
'is_show_report': val.is_show_report
}
this.documentsAndFilesList.push(DocumentsAndFiles);
});
}
}
else {
this.documentsAndFilesList = [];
this.documentsAndFilesList = [];
}
});
}
});
}
}

View File

@ -30,13 +30,13 @@ export const environment = {
// }
firebase: {
apiKey: "AIzaSyCk86rasBR2-sXlVu6ACUO406EM_1mcwgo",
authDomain: "pdgenie-prod.firebaseapp.com",
databaseURL: "https://pdgenie-prod.firebaseio.com%26quot%3B%2C/",
projectId: "pdgenie-prod",
storageBucket: "",
messagingSenderId: "906855209078",
appId: "1:906855209078:web:c1583378f1fb2c71"
}
apiKey: "AIzaSyCk86rasBR2-sXlVu6ACUO406EM_1mcwgo",
authDomain: "pdgenie-prod.firebaseapp.com",
databaseURL: "https://pdgenie-prod.firebaseio.com%26quot%3B%2C/",
projectId: "pdgenie-prod",
storageBucket: "",
messagingSenderId: "906855209078",
appId: "1:906855209078:web:c1583378f1fb2c71"
}
};