From aeb2bab3562753bb8350c2fb1db4a1dfa3c895a0 Mon Sep 17 00:00:00 2001 From: Akisha Date: Mon, 12 Nov 2018 19:00:14 +0530 Subject: [PATCH] New Form STOCK, FINANCE, EMP-INFO, BUSINESS-INFO --- .../forms/address/address.component.html | 3 +- .../banking-details.component.html | 9 +- .../banking-details.component.ts | 13 +- .../business-info.component.html | 306 ++++++++++++++++++ .../business-info.component.scss | 24 ++ .../business-info/business-info.component.ts | 290 +++++++++++++++++ .../client-info/client-info.component.ts | 6 +- .../current-loan/current-loan.component.html | 9 +- .../current-loan/current-loan.component.scss | 1 - .../current-loan/current-loan.component.ts | 5 +- .../employment-info.component.html | 71 ++++ .../employment-info.component.scss | 21 ++ .../employment-info.component.ts | 120 +++++++ .../family-details.component.html | 3 +- .../financial-info.component.html | 85 +++++ .../financial-info.component.scss | 18 ++ .../financial-info.component.ts | 163 ++++++++++ .../loan-details/loan-details.component.html | 148 ++++++--- .../loan-details/loan-details.component.scss | 3 + .../loan-details/loan-details.component.ts | 210 ++++++++---- .../other-income/other-income.component.html | 9 +- .../other-income/other-income.component.scss | 1 - .../other-income/other-income.component.ts | 3 + .../start-pd/forms/stock/stock.component.html | 81 +++++ .../start-pd/forms/stock/stock.component.scss | 18 ++ .../start-pd/forms/stock/stock.component.ts | 151 +++++++++ .../list-pd/start-pd/start-pd.component.html | 16 + .../list-pd/start-pd/start-pd.component.ts | 115 ++++--- .../manage-pd/manage-pd.module.ts | 6 +- 29 files changed, 1740 insertions(+), 168 deletions(-) create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.html create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.scss create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.ts create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.html create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.scss create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.ts create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.scss create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.html create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.scss create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.ts diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html index 8817c55f5..ac30af556 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html @@ -1,3 +1,4 @@ +

Address

@@ -104,4 +105,4 @@ - +
\ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/banking-details/banking-details.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/banking-details/banking-details.component.html index 756612cc6..a9ecfeeb3 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/banking-details/banking-details.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/banking-details/banking-details.component.html @@ -1,16 +1,17 @@ +
- +

{{i+1}} Banking details - add + add - delete + delete

@@ -63,4 +64,4 @@ - + \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/banking-details/banking-details.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/banking-details/banking-details.component.ts index fd7e5155f..8b1decbd5 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/banking-details/banking-details.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/banking-details/banking-details.component.ts @@ -81,16 +81,21 @@ export class BankingDetailsComponent implements OnInit { vintage: ['', Validators.compose([Validators.required])], }); } - addBankdetails(i) { - this.step = i++; + addBankdetails(event) { + event.stopPropagation(); const control = this.bankingForm.controls['itemRows']; + let length = control.length; + this.step = length; control.push(this.createBankarray()); } - deleteBankdetails(index: number) { + deleteBankdetails(index: number, event) { + event.stopPropagation(); const control = this.bankingForm.controls['itemRows']; control.removeAt(index); } - + setStep(index: number) { + this.step = index; + } bankSubmit() { if (!this.bankingForm.valid) { this.validateAllFormFields(this.bankingForm); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.html new file mode 100644 index 000000000..5af3fd5af --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.html @@ -0,0 +1,306 @@ + +

Business Details

+
+ + + + + + + + + {{list.name}} + + + + + {{type.name}} + + + + + + + +

Designation +

+ +

+
+ + + + + + + + + + +
+
+
+ + + Started by Applicant + Family Business + + + + + One of the applicants + Relative of an applicant + Others + + + + + + + + {{member.name}} + + + + + + + + + + +

Partners / Directors / Shareholders +

+ +

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

Employees As per applicant +

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

As per PD Officer +

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

Investments +

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

Location +

+ + + + + Well Suited. + Fairly Suited + Not Suited + + + + + + +

Business Setup +

+ + + + + self owned + Rented + Family Owned + others + + + + + + + + + + + + +

Is the below documents seen and photo captured ? +

+ + + + + Yes + No + + + + + Yes + No + + + + + Yes + No + + + + + Yes + No + + + + + Yes + No + + + + + Yes + No + + + + + Yes + No + + + + + Yes + No + + +

+
+ + + + + +
+
+ +
+ + + + +
+
\ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.scss new file mode 100644 index 000000000..3be75d28c --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.scss @@ -0,0 +1,24 @@ +.address { + display: flex; + padding: 0 2%; + flex-direction: column; +} + +.address > * { + width: 100%; +} +.matcard > * { + width: 80%; +} +.card mat-form-field { + margin: 0 2%; +} +.matcard mat-form-field { + margin: 0 2%; +} +.address .button { + float: right; + width: 10px; + background: #62B013; + color: white; +} \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.ts new file mode 100644 index 000000000..225c770ef --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-info/business-info.component.ts @@ -0,0 +1,290 @@ +import { + Component, + OnInit, + Inject, + Input +} from '@angular/core'; + +import { + FormBuilder, + FormGroup, + Validators, + FormArray, FormControl, AbstractControl, +} from '@angular/forms'; + +import { NotifierService } from 'angular-notifier'; + +import { + MatDialog, + MatDialogRef, + MAT_DIALOG_DATA +} from '@angular/material'; +/** Service */ +import { PdTrigerService } from '../../../../../pd-service/pd-triger.service'; +import {ActivatedRoute, Router} from "@angular/router"; +@Component({ + selector: 'app-business-info', + templateUrl: './business-info.component.html', + styleUrls: ['./business-info.component.scss'] +}) +export class BusinessInfoComponent implements OnInit { + @Input() pdid: number; + @Input() form_id: number; + relationData: any = []; + industryData: any = []; + activityData: any = []; + relativeNames: any; + public businessForm: FormGroup; + private notifier: NotifierService; + + constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute, + private router: Router, + private _pd: PdTrigerService) { + this.notifier = notifier; + } + ngOnInit() { + this.getRelation(); + this.getIndustry(); + this.getActivity(); + this.initBusinessForm(); + // const Desgn = this.businessForm.controls['designation']; + // const Partnr = this.businessForm.controls['partners']; + // const otherDoc = this.businessForm.controls['documents']; + let params: any = {}; + params.pd_id = this.pdid; + params.pd_form_id = this.form_id; + this._pd.retriveForm(params).subscribe(data => { + let businessVal = data.records; + console.log('data', businessVal); + let constVal: any; + const Desgn = this.businessForm.controls['designation']; + const Partnr = this.businessForm.controls['partners']; + const otherDoc = this.businessForm.controls['documents']; + + if (data.status == 200) { + let DocArray: any; + let DesgnArray = Object.keys(data.records.designation).map(function (key) { + return data.records.designation[key]; + }); + let PartnrArray = Object.keys(data.records.partners).map(function (key) { + return data.records.partners[key]; + }); + + let selectedMembers = Object.keys(data.records.family_members_involved).map(function (key) { + return data.records.family_members_involved[key]; + }); + let enduse: any = []; + selectedMembers.forEach(val => { + enduse.push(val.member); + }); + if (DesgnArray.length == 0) { + Desgn.push(this.createDesignation()); + } else { + Desgn.push(this.createDesignation()); + } + if (PartnrArray.length == 0) { + Partnr.push(this.createPartners()); + } else { + PartnrArray.forEach(datas => { + Partnr.push(this.createPartners()); + }); + } + if (data.other_documents == 'yes') { + DocArray = Object.keys(data.records.documents).map(function (key) { + return data.records.documents[key]; + }); + DocArray.forEach(datas => { + otherDoc.push(this.createDocument()); + }); + } else { + DocArray = [{document: ''}]; + otherDoc.push(this.createDocument()); + } + if (data.records.ownership_setup != 'others') { + businessVal.ownership_others = ''; + } + if (data.records.ownership_setup != 'rented') { + businessVal.rent_paid = ''; + } + businessVal.family_members_involved = enduse; + businessVal.pdid = this.pdid; + businessVal.formid = this.form_id; + businessVal.fk_createdby = this.pdid; + businessVal.designation = DesgnArray; + businessVal.partners = PartnrArray; + businessVal.documents = DocArray; + console.log('businessVal', businessVal); + + this.businessForm.setValue(businessVal); + } else { + Desgn.push(this.createDesignation()); + Partnr.push(this.createPartners()); + otherDoc.push(this.createDocument()); + } + + }); + // Desgn.push(this.createDesignation()); + // Partnr.push(this.createPartners()); + // otherDoc.push(this.createDocument()); + } + public initBusinessForm(): void { + this.businessForm = this.fb.group({ + pdid: this.pdid, + formid: this.form_id, + fk_createdby: this.pdid, + profession_name: ['', Validators.compose([Validators.required])], + business_years: ['', Validators.compose([Validators.required])], + industry: ['', Validators.compose([Validators.required])], + type_of_activity: ['', Validators.compose([Validators.required])], + seasonality: ['', Validators.compose([Validators.required])], + designation: this.fb.array([]), + partners: this.fb.array([]), + employees_total: ['', Validators.compose([Validators.required])], + employees_permanent: ['', Validators.compose([Validators.required])], + employees_temporary: ['', Validators.compose([Validators.required])], + officer_total: ['', Validators.compose([Validators.required])], + officer_permanent: ['', Validators.compose([Validators.required])], + officer_temporary: ['', Validators.compose([Validators.required])], + invested_amount: ['', Validators.compose([Validators.required])], + working_capital: ['', Validators.compose([Validators.required])], + is_service_provided: ['', Validators.compose([Validators.required])], + ownership_setup: ['', Validators.compose([Validators.required])], + ownership_others: [''], + rent_paid: [''], + shop_eat_act_cert: ['', Validators.compose([Validators.required])], + gst_Regn_cert: ['', Validators.compose([Validators.required])], + export_import_cert: ['', Validators.compose([Validators.required])], + factory_cert: ['', Validators.compose([Validators.required])], + practice_cert: ['', Validators.compose([Validators.required])], + pf_regn: ['', Validators.compose([Validators.required])], + esic_regn: ['', Validators.compose([Validators.required])], + other_documents: ['', Validators.compose([Validators.required])], + documents: this.fb.array([]), + business_remarks: ['', Validators.compose([Validators.required])], + who_started: ['', Validators.compose([Validators.required])], + main_person: ['', Validators.compose([Validators.required])], + other_main_person: [''], + family_members_involved: ['', Validators.compose([Validators.required])], + before_business: ['', Validators.compose([Validators.required])], + any_delays: ['', Validators.compose([Validators.required])], + }); + } + createDesignation(): FormGroup { + return this.fb.group({ + sec_name: ['', Validators.compose([Validators.required])], + sec_designation: ['', Validators.compose([Validators.required])], + }); + } + createPartners(): FormGroup { + return this.fb.group({ + partner_name: ['', Validators.compose([Validators.required])], + shareholding: ['', Validators.compose([Validators.required])], + current_business_experiance: ['', Validators.compose([Validators.required])], + total_business_experiance: ['', Validators.compose([Validators.required])], + }); + } + createDocument() { + return this.fb.group({ + document: [''] + }); + } + addDesignation() { + const control = this.businessForm.controls['designation']; + control.push(this.createDesignation()); + } + deleteDesignation(index) { + const control = this.businessForm.controls['designation']; + control.removeAt(index); + } + addPartnerDetails() { + const control = this.businessForm.controls['partners']; + control.push(this.createPartners()); + } + deletePartnerDetails(index) { + const control = this.businessForm.controls['partners']; + control.removeAt(index); + } + addDocuments() { + const control = this.businessForm.controls['documents']; + control.push(this.createDocument()); + } + deleteDocuments(index) { + const control = this.businessForm.controls['documents']; + control.removeAt(index); + } + getRelation() { + let master_name = 'RELATIONSHIPS'; + this._pd.getAllMasterDatas(master_name).subscribe(data => { + console.log('data', data); + data.records.forEach(val => { + if (val.isactive == 1) { + this.relationData.push(val); + } + }) + }); + } + relationChanged(event) { + this.relativeNames = []; + event.value.forEach(option => { + this.relativeNames.push({member: option}); + }); + } + getIndustry() { + let master_name = 'INDUSTRYCLASSIFICATION'; + this._pd.getAllMasterDatas(master_name).subscribe(data => { + console.log('data', data); + data.records.forEach(val => { + if (val.isactive == 1) { + this.industryData.push(val); + } + }) + }); + } + getActivity() { + let master_name = 'TYPEOFACTIVITY'; + this._pd.getAllMasterDatas(master_name).subscribe(data => { + console.log('data', data); + data.records.forEach(val => { + if (val.isactive == 1) { + this.activityData.push(val); + } + }) + }); + } + submitDetails() { + let family: any = []; + if (!this.businessForm.valid) { + console.log('form', this.businessForm) + return; + } + let design: any; + let records = this.businessForm.value; + if (records.other_documents == 'no') { + delete records.documents; + } + if (records.rent_paid == '') { + delete records.rent_paid; + } + if (records.ownership_others == '') { + delete records.ownership_others; + } + records.family_members_involved = this.relativeNames; + console.log('recordss', records); + this._pd.saveForm(records).subscribe(data => { + console.log('data', data); + this.notifier.notify('success', 'Saved Successfully.'); + }, error => { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + }); + } + validateAllFormFields(formGroup: FormGroup) { + Object.keys(formGroup.controls).forEach(field => { + const control = formGroup.get(field); + if (control instanceof FormControl) { + control.markAsTouched({onlySelf: true}); + } else if (control instanceof FormGroup) { + this.validateAllFormFields(control); + } + }); + } +} diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/client-info/client-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/client-info/client-info.component.ts index 5e373360f..cc1911240 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/client-info/client-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/client-info/client-info.component.ts @@ -200,12 +200,10 @@ var result = Object.keys(supp_data).map(function(key) { this.paymentModeTextBox = e.value; // this.f.supplier_details.controls.get('payment_mode_value'); } - public freqPurchaseTextBox: number; selectedFreqPurchase(e){ this.freqPurchaseTextBox = e.value; } - /** To Save/Edited Popup Data */ onSubmit() { @@ -216,10 +214,10 @@ var result = Object.keys(supp_data).map(function(key) { } else { var answerFormValues = this._supplierQuesFrom.value; - //To Remove The "Null" With Key also + // To Remove The "Null" With Key also Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); alert(JSON.stringify(answerFormValues)); - //Add BRANCH data with help Service File + // Add BRANCH data with help Service File this.pdTrigerService.savePDFormDetailsWithID(answerFormValues).subscribe( dataresult => { if (dataresult.status == 200) { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.html index a21f4548e..39ec48a86 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.html @@ -1,3 +1,4 @@ +

Current Loan Details

@@ -45,5 +46,9 @@
- - \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.scss index 04f58a38e..db319b869 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.scss +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.scss @@ -12,7 +12,6 @@ } .address .button { float: right; - height: 10px; width: 10px; background: #62B013; color: white; diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.ts index 30248aa13..f73d6c725 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.ts @@ -52,6 +52,7 @@ export class CurrentLoanComponent implements OnInit { return value.records.loan_details[key]; }); this.currentLoanForm.controls['existing_loan'].setValue(value.records.existing_loan); + this.currentLoanForm.controls['currentloan_remarks'].setValue(value.records.currentloan_remarks); if (result.length > 0) { result.forEach(val => { control.push(this.createLoanDetail()); @@ -68,7 +69,8 @@ export class CurrentLoanComponent implements OnInit { public initCurrentloanForm(): void { this.currentLoanForm = this.fb.group({ existing_loan: ['', Validators.compose([Validators.required])], - loan_details: this.fb.array([]) + currentloan_remarks: ['', Validators.compose([Validators.required])], + loan_details: this.fb.array([]), }); } createLoanDetail() { @@ -99,6 +101,7 @@ export class CurrentLoanComponent implements OnInit { records.formid = this.form_id; records.fk_createdby = this.pdid; records.existing_loan = this.currentLoanForm.controls['existing_loan'].value; + records.currentloan_remarks = this.currentLoanForm.controls['currentloan_remarks'].value; records.loan_details = this.currentLoanForm.controls['loan_details'].value; console.log('data', records); this._pd.saveForm(records).subscribe(data => { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.html new file mode 100644 index 000000000..4b92a9f61 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.html @@ -0,0 +1,71 @@ + +
+ + + + + + + + + Yes + No + + + + + + + + Yes + No + + + + + + + + Yes + No + + + + + Yes + No + + + + +

Salary Details

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

+
\ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.scss new file mode 100644 index 000000000..8c61eec1d --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.scss @@ -0,0 +1,21 @@ +.address { + display: flex; + padding: 0 2%; + flex-direction: column; +} + +.address > * { + width: 100%; +} +.matcard > * { + width: 80%; +} +.matcard mat-form-field { + margin: 0 2%; +} +.address .button { + float: right; + width: 10px; + background: #62B013; + color: white; +} \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.ts new file mode 100644 index 000000000..e73af719b --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.ts @@ -0,0 +1,120 @@ +import { + Component, + OnInit, + Inject, + Input +} from '@angular/core'; + +import { + FormBuilder, + FormGroup, + Validators, + FormArray, FormControl, +} from '@angular/forms'; + +import { NotifierService } from 'angular-notifier'; + +import { + MatDialog, + MatDialogRef, + MAT_DIALOG_DATA +} from '@angular/material'; +/** Service */ +import { PdTrigerService } from '../../../../../pd-service/pd-triger.service'; +import {ActivatedRoute, Router} from '@angular/router'; +@Component({ + selector: 'app-employment-info', + templateUrl: './employment-info.component.html', + styleUrls: ['./employment-info.component.scss'] +}) +export class EmploymentInfoComponent implements OnInit { + @Input() pdid: number; + @Input() form_id: number; + public employmentForm: FormGroup; + private notifier: NotifierService; + + constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute, + private router: Router, + private _pd: PdTrigerService) { + this.notifier = notifier; + } + ngOnInit() { + this.initemploymentForm(); + let params: any = {}; + params.pd_id = this.pdid; + params.pd_form_id = this.form_id; + this._pd.retriveForm(params).subscribe(value => { + console.log('value', value); + if (value.status == 200) { + this.employmentForm.controls['employer_name'].setValue(value.records.employer_name); + this.employmentForm.controls['how_long'].setValue(value.records.how_long); + this.employmentForm.controls['was_met'].setValue(value.records.was_met); + if (value.records.name_designation) { + this.employmentForm.controls['name_designation'].setValue(value.records.name_designation); + } + this.employmentForm.controls['confirm_salary'].setValue(value.records.confirm_salary); + if (value.records.confirm_salary_amount) { + this.employmentForm.controls['confirm_salary_amount'].setValue(value.records.confirm_salary_amount); + } + this.employmentForm.controls['attendance_seen'].setValue(value.records.attendance_seen); + this.employmentForm.controls['sal_reg_seen'].setValue(value.records.sal_reg_seen); + this.employmentForm.controls['gross'].setValue(value.records.gross); + this.employmentForm.controls['net_take_home'].setValue(value.records.net_take_home); + this.employmentForm.controls['bonus_incentive'].setValue(value.records.bonus_incentive); + this.employmentForm.controls['any_delays'].setValue(value.records.any_delays); + this.employmentForm.controls['employment_remarks'].setValue(value.records.employment_remarks); + } + }) + } + public initemploymentForm(): void { + this.employmentForm = this.fb.group({ + employer_name: ['', Validators.compose([Validators.required])], + how_long: ['', Validators.compose([Validators.required])], + was_met: ['', Validators.compose([Validators.required])], + name_designation: [''], + confirm_salary: ['', Validators.compose([Validators.required])], + confirm_salary_amount: [''], + attendance_seen: ['', Validators.compose([Validators.required])], + sal_reg_seen: ['', Validators.compose([Validators.required])], + gross: ['', Validators.compose([Validators.required])], + net_take_home: ['', Validators.compose([Validators.required])], + bonus_incentive: ['', Validators.compose([Validators.required])], + any_delays: ['', Validators.compose([Validators.required])], + employment_remarks: ['', Validators.compose([Validators.required])], + }); + } + submitDetails() { + if (!this.employmentForm.valid) { + return; + } + let records: any = {}; + records.pdid = this.pdid; + records.formid = this.form_id; + records.fk_createdby = this.pdid; + records.employer_name = this.employmentForm.controls['employer_name'].value; + records.how_long = this.employmentForm.controls['how_long'].value; + records.was_met = this.employmentForm.controls['was_met'].value; + if (this.employmentForm.controls['was_met'].value == 'yes') { + records.name_designation = this.employmentForm.controls['name_designation'].value; + } + records.confirm_salary = this.employmentForm.controls['confirm_salary'].value; + if (this.employmentForm.controls['confirm_salary'].value == 'yes') { + records.confirm_salary_amount = this.employmentForm.controls['confirm_salary_amount'].value; + } + records.attendance_seen = this.employmentForm.controls['attendance_seen'].value; + records.sal_reg_seen = this.employmentForm.controls['sal_reg_seen'].value; + records.gross = this.employmentForm.controls['gross'].value; + records.net_take_home = this.employmentForm.controls['net_take_home'].value; + records.bonus_incentive = this.employmentForm.controls['bonus_incentive'].value; + records.any_delays = this.employmentForm.controls['any_delays'].value; + records.employment_remarks = this.employmentForm.controls['employment_remarks'].value; + console.log('data', records); + this._pd.saveForm(records).subscribe(data => { + console.log('data', data); + this.notifier.notify('success', 'Saved Successfully.'); + }, error => { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + }) + } + +} diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.html index 2c7dacbca..c535549be 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.html @@ -1,3 +1,4 @@ +

Family

@@ -132,4 +133,4 @@ - +
\ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html new file mode 100644 index 000000000..23e0c28fe --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html @@ -0,0 +1,85 @@ + +
+ + +

Data as per Financial statements

+ +

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

Estimated Value

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + +
+
\ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.scss new file mode 100644 index 000000000..db319b869 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.scss @@ -0,0 +1,18 @@ +.address { + display: flex; + padding: 0 2%; + flex-direction: column; +} + +.address > * { + width: 100%; +} +.matcard mat-form-field { + margin: 0 2%; +} +.address .button { + float: right; + width: 10px; + background: #62B013; + color: white; +} \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts new file mode 100644 index 000000000..98d10651b --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts @@ -0,0 +1,163 @@ +import { + Component, + OnInit, + Inject, + Input +} from '@angular/core'; + +import { + FormBuilder, + FormGroup, + Validators, + FormArray, FormControl, AbstractControl, +} from '@angular/forms'; + +import { NotifierService } from 'angular-notifier'; + +import { + MatDialog, + MatDialogRef, + MAT_DIALOG_DATA +} from '@angular/material'; +/** Service */ +import { PdTrigerService } from '../../../../../pd-service/pd-triger.service'; +import {ActivatedRoute, Router} from '@angular/router'; +@Component({ + selector: 'app-financial-info', + templateUrl: './financial-info.component.html', + styleUrls: ['./financial-info.component.scss'] +}) +export class FinancialInfoComponent implements OnInit { + @Input() pdid: number; + @Input() form_id: number; + public financialForm: FormGroup; + private notifier: NotifierService; + marginVal: any = [] ; + setmargin: AbstractControl; + constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute, + private router: Router, + private _pd: PdTrigerService) { + this.notifier = notifier; + } + ngOnInit() { + this.initstockForm(); + let params: any = {}; + params.pd_id = this.pdid; + params.pd_form_id = this.form_id; + this._pd.retriveForm(params).subscribe(value => { + console.log('value', value); + // const rawMaterial = this.financialForm.controls['raw_materials']; + // const finishedGoods = this.financialForm.controls['finished_goods']; + // if (value.status == 200) { + // let result = Object.keys(value.records.raw_materials).map(function(key) { + // return value.records.raw_materials[key]; + // }); + // let result_Goods = Object.keys(value.records.finished_goods).map(function(key) { + // return value.records.finished_goods[key]; + // }); + // this.stockForm.controls['stock_remarks'].setValue(value.records.stock_remarks); + // if (result.length > 0) { + // result.forEach(val => { + // rawMaterial.push(this.createRawmaterial()); + // }); + // this.stockForm.controls['raw_materials'].setValue(result); + // } else { + // rawMaterial.push(this.createRawmaterial()); + // } + // if (result_Goods.length > 0) { + // result_Goods.forEach(val => { + // finishedGoods.push(this.createGoods()); + // }); + // this.stockForm.controls['finished_goods'].setValue(result_Goods); + // } else { + // finishedGoods.push(this.createGoods()); + // } + // } else { + // rawMaterial.push(this.createRawmaterial()); + // finishedGoods.push(this.createGoods()); + // } + }) + } + public initstockForm(): void { + this.financialForm = this.fb.group({ + financial_remarks: ['', Validators.compose([Validators.required])], + date_per_financial: this.fb.array([this.createDate()]), + estimated_value: this.fb.array([this.createValue()]) + }); + } + createDate() { + return this.fb.group({ + financial_year: ['', Validators.compose([Validators.required, Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])], + financial_annual_sale: ['', Validators.compose([Validators.required, Validators.pattern(/^[0-9\(\)]+$/)])], + financial_net_profit: ['', Validators.compose([Validators.required, Validators.pattern(/^-?[1-9]\d*|0$/)])], + financial_margin: ['', Validators.compose([Validators.required])], + financial_variation: ['', Validators.compose([Validators.required])], + financial_reason: ['', Validators.compose([Validators.required])], + }); + } + createValue() { + return this.fb.group({ + estimate_year: ['', Validators.compose([Validators.required, Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])], + estimate_annual_sale: ['', Validators.compose([Validators.required, Validators.pattern(/^[0-9]$/)])], + estimate_net_profit: ['', Validators.compose([Validators.required, Validators.pattern(/^-?[1-9]\d*|0$/)])], + estimate_margin: ['', Validators.compose([Validators.required])], + estimate_variation: ['', Validators.compose([Validators.required])], + estimate_reason: ['', Validators.compose([Validators.required])], + }); + } + addDate() { + const control = this.financialForm.controls['date_per_financial']; + control.push(this.createDate()); + } + deleteDate(index) { + const control = this.financialForm.controls['date_per_financial']; + control.removeAt(index); + } + addGoods() { + const control = this.financialForm.controls['estimated_value']; + control.push(this.createValue()); + } + deleteGoods(index) { + const control = this.financialForm.controls['estimated_value']; + control.removeAt(index); + } + calMargin(event, index) { + let salary = this.financialForm.controls['date_per_financial'].value[index].financial_annual_sale; + console.log(event.target.value); + console.log('salary', salary); + let margin = event.target.value / salary * 100; + this.financialForm.controls['date_per_financial'].value[index].financial_annual_sale = margin.toFixed(2); + this.financialForm.controls['date_per_financial'].setValue(this.financialForm.controls['date_per_financial']); + } + submitDetails() { + if (!this.financialForm.valid) { + this.validateAllFormFields(this.financialForm); + return; + } + // let records: any = {}; + // records.pdid = this.pdid; + // records.formid = this.form_id; + // records.fk_createdby = this.pdid; + // records.raw_materials = this.stockForm.controls['raw_materials'].value; + // records.stock_remarks = this.stockForm.controls['stock_remarks'].value; + // records.finished_goods = this.stockForm.controls['finished_goods'].value; + // console.log('data', records); + // this._pd.saveForm(records).subscribe(data => { + // console.log('data', data); + // this.notifier.notify('success', 'Saved Successfully.'); + // }, error => { + // this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + // }) + // } + } + validateAllFormFields(formGroup: FormGroup) { + Object.keys(formGroup.controls).forEach(field => { + const control = formGroup.get(field); + if (control instanceof FormControl) { + control.markAsTouched({onlySelf: true}); + } else if (control instanceof FormGroup) { + this.validateAllFormFields(control); + } + }); + } +} diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.html index 617e657ef..4bbaa6ff3 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.html @@ -1,48 +1,120 @@ +
- - Yes - No + + Puchase of property + Construction + Extention + Improvement + Working capital + Purchase of business asset + to close an existing debt + Other purpose - + + + + + + Yes + No + + + + + Yes + No + + + + + + + + + + + + + + + + + + Borrowed from Relatives & Friends + Own money + Loan from another lender + + + + + + + + + -

Loan Details

+

Mortgage +

-

-
- - - - Rental Income - Interest Income - Agricultural Income - Dividend Income and Others - - - - - - - - - - - -
-
+ + + + Bungalow + Flat + Row House + Floor + Chawl + Shed + Office + Shop in a market + shop in a mall + standalone shop + clinic + Factory + Vacant Land + Others + + + + + + + + {{owner.applicant_name}} + + + + + Under-construction + Complete + Vacant Land + + + + + + + + + +
- - \ No newline at end of file + + + + + +
\ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.scss index db319b869..8c61eec1d 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.scss +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.scss @@ -7,6 +7,9 @@ .address > * { width: 100%; } +.matcard > * { + width: 80%; +} .matcard mat-form-field { margin: 0 2%; } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.ts index 9bc956f27..6ff07a5ce 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/loan-details/loan-details.component.ts @@ -30,74 +30,168 @@ import {ActivatedRoute, Router} from '@angular/router'; export class LoanDetailsComponent implements OnInit { public loanDetailsForm: FormGroup; private notifier: NotifierService; - frequencyData: any; - + @Input() pdid: number; + @Input() form_id: number; + @Input() applicant_details: any; + applicants: any; + isOtherPurpose: boolean = false; + isSource: boolean = false; + endUserList: any = []; + ownerNames: any = []; constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute, private router: Router, private _pd: PdTrigerService) { + this.notifier = notifier; } ngOnInit() { + this.applicants = this.applicant_details.pdapplicants_detials; this.initloanDetailsForm(); - // this.getFrequency(); + let params: any = {}; + params.pd_id = this.pdid; + params.pd_form_id = this.form_id; + this._pd.retriveForm(params).subscribe(value => { + console.log('value', value); + if (value.status == 200) { + let result = Object.keys(value.records.end_use_group).map(function(key) { + return value.records.end_use_group[key]; + }); + let owner = Object.keys(value.records.owner_name_group).map(function(key) { + return value.records.owner_name_group[key]; + }); + + let enduse: any = []; + result.forEach(val => { + enduse.push(val.end_use); + }); + let ownername: any = []; + owner.forEach(val => { + ownername.push(val.owner_name); + }); + console.log('enduse', enduse); + console.log('ownername', ownername); + this.loanDetailsForm.controls['loan_amount'].setValue(value.records.loan_amount); + this.loanDetailsForm.controls['end_use'].setValue(enduse); + if (value.records.end_use_other) { + this.loanDetailsForm.controls['end_use_other'].setValue(value.records.end_use_other); + } + this.loanDetailsForm.controls['is_transfer'].setValue(value.records.is_transfer); + this.loanDetailsForm.controls['is_topup'].setValue(value.records.is_topup); + if (value.records.balance_transfer_amount) { + this.loanDetailsForm.controls['balance_transfer_amount'].setValue(value.records.balance_transfer_amount); + } + if (value.records.topup_amount) { + this.loanDetailsForm.controls['topup_amount'].setValue(value.records.topup_amount); + } + if (value.records.lender) { + this.loanDetailsForm.controls['lender'].setValue(value.records.lender); + } + this.loanDetailsForm.controls['own_contribution'].setValue(value.records.own_contribution); + this.loanDetailsForm.controls['source'].setValue(value.records.source); + if (value.records.lender_name_type) { + this.loanDetailsForm.controls['lender_name_type'].setValue(value.records.lender_name_type); + } + this.loanDetailsForm.controls['emi_level'].setValue(value.records.emi_level); + this.loanDetailsForm.controls['property_type'].setValue(value.records.property_type); + this.loanDetailsForm.controls['owner_name'].setValue(ownername); + this.loanDetailsForm.controls['construction_status'].setValue(value.records.construction_status); + this.loanDetailsForm.controls['emv_per_customer'].setValue(value.records.emv_per_customer); + this.loanDetailsForm.controls['value_per_agreement'].setValue(value.records.value_per_agreement); + this.loanDetailsForm.controls['loandetails_remarks'].setValue(value.records.loandetails_remarks); + } + }) } public initloanDetailsForm(): void { this.loanDetailsForm = this.fb.group({ - other_income: ['', Validators.compose([Validators.required])], - // income_details: this.fb.array([this.createDetail()]) + loan_amount: ['', Validators.compose([Validators.required])], + end_use: ['', Validators.compose([Validators.required])], + end_use_other: [''], + is_transfer: ['', Validators.compose([Validators.required])], + is_topup: ['', Validators.compose([Validators.required])], + balance_transfer_amount: [''], + topup_amount: [''], + lender: [''], + own_contribution: ['', Validators.compose([Validators.required])], + source: ['', Validators.compose([Validators.required])], + lender_name_type: [''], + emi_level: ['', Validators.compose([Validators.required])], + property_type: ['', Validators.compose([Validators.required])], + owner_name: ['', Validators.compose([Validators.required])], + construction_status: ['', Validators.compose([Validators.required])], + emv_per_customer: ['', Validators.compose([Validators.required])], + value_per_agreement: ['', Validators.compose([Validators.required])], + loandetails_remarks: ['', Validators.compose([Validators.required])], + }); + } + endUserChange(event) { + this.endUserList = []; + event.value.forEach(option => { + this.endUserList.push({end_use: option}); + if (option == 'other') { + this.isOtherPurpose = true; + } + }); + } + ownerNameChange(event) { + this.ownerNames = []; + event.value.forEach(option => { + this.ownerNames.push({owner_name: option}); + }); + } + submitLoanDetails() { + console.log('formData', this.loanDetailsForm.value); + if (!this.loanDetailsForm.valid) { + this.validateAllFormFields(this.loanDetailsForm); + return; + } + let records: any = {}; + records.pdid = this.pdid; + records.formid = this.form_id; + records.fk_createdby = this.pdid; + records.loan_amount = this.loanDetailsForm.controls['loan_amount'].value; + records.end_use_group = this.endUserList; + if (this.isOtherPurpose) { + records.end_use_other = this.loanDetailsForm.controls['end_use_other'].value; + } + records.is_transfer = this.loanDetailsForm.controls['is_transfer'].value; + records.is_topup = this.loanDetailsForm.controls['is_topup'].value; + if (this.loanDetailsForm.controls['is_transfer'].value == 'yes') { + records.balance_transfer_amount = this.loanDetailsForm.controls['balance_transfer_amount'].value; + } + if (this.loanDetailsForm.controls['is_topup'].value == 'yes') { + records.topup_amount = this.loanDetailsForm.controls['topup_amount'].value; + } + if (this.loanDetailsForm.controls['is_topup'].value == 'yes' || this.loanDetailsForm.controls['is_transfer'].value == 'yes') { + records.lender = this.loanDetailsForm.controls['lender'].value; + } + records.own_contribution = this.loanDetailsForm.controls['own_contribution'].value; + records.source = this.loanDetailsForm.controls['source'].value; + if (this.loanDetailsForm.controls['source'].value == 'other') { + records.lender_name_type = this.loanDetailsForm.controls['lender_name_type'].value; + } + records.emi_level = this.loanDetailsForm.controls['emi_level'].value; + records.property_type = this.loanDetailsForm.controls['property_type'].value; + records.owner_name_group = this.ownerNames; + records.construction_status = this.loanDetailsForm.controls['construction_status'].value; + records.emv_per_customer = this.loanDetailsForm.controls['emv_per_customer'].value; + records.value_per_agreement = this.loanDetailsForm.controls['value_per_agreement'].value; + records.loandetails_remarks = this.loanDetailsForm.controls['loandetails_remarks'].value; + console.log('data', records); + this._pd.saveForm(records).subscribe(data => { + console.log('data', data); + this.notifier.notify('success', 'Saved Successfully.'); + }, error => { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + }) + } + validateAllFormFields(formGroup: FormGroup) { + Object.keys(formGroup.controls).forEach(field => { + const control = formGroup.get(field); + if (control instanceof FormControl) { + control.markAsTouched({onlySelf: true}); + } else if (control instanceof FormGroup) { + this.validateAllFormFields(control); + } }); } - // createDetail() { - // return this.fb.group({ - // source: ['', Validators.compose([Validators.required])], - // amount: ['', Validators.compose([Validators.required])], - // frequency: ['', Validators.compose([Validators.required])], - // }); - // } - // getFrequency() { - // let master_name = 'FREQUENCY'; - // this._pd.getAllMasterDatas(master_name).subscribe(data => { - // console.log('data', data); - // data.records.forEach(val => { - // if (val.isactive == 1) { - // this.frequencyData.push(val); - // } - // }) - // }); - // } - // addIncomeDetails() { - // const control = this.otherIncomeForm.controls['income_details']; - // control.push(this.createDetail()); - // } - // deleteIncomeDetails(index) { - // const control = this.otherIncomeForm.controls['income_details']; - // control.removeAt(index); - // } - // submitCurrentDetails() { - // if (!this.otherIncomeForm.valid) { - // this.validateAllFormFields(this.otherIncomeForm); - // return; - // } - // let records: any = {}; - // records.pdid = '25‎4'; - // records.formid = '25‎4'; - // records.fk_createdby = '25‎4'; - // records.other_income = this.otherIncomeForm.controls['other_income'].value; - // records.income_details = this.otherIncomeForm.controls['income_details'].value; - // console.log('data', records); - // this._pd.saveForm(records).subscribe(data => { - // console.log('data', data); - // this.notifier.notify('success', 'Saved Successfully.'); - // }) - // } - // validateAllFormFields(formGroup: FormGroup) { - // Object.keys(formGroup.controls).forEach(field => { - // const control = formGroup.get(field); - // if (control instanceof FormControl) { - // control.markAsTouched({onlySelf: true}); - // } else if (control instanceof FormGroup) { - // this.validateAllFormFields(control); - // } - // }); - // } } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.html index 361ae1ff9..152416d0d 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.html @@ -1,3 +1,4 @@ +
- - \ No newline at end of file + + + + + +
\ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.scss index 100dc0b17..db319b869 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.scss +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.scss @@ -13,7 +13,6 @@ .address .button { float: right; width: 10px; - height: 10px; background: #62B013; color: white; } \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts index 49ddd9cf3..f0b03b565 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts @@ -53,6 +53,7 @@ export class OtherIncomeComponent implements OnInit { return value.records.income_details[key]; }); this.otherIncomeForm.controls['other_income'].setValue(value.records.other_income); + this.otherIncomeForm.controls['otherincome_remarks'].setValue(value.records.otherincome_remarks); if (result.length > 0) { result.forEach(val => { control.push(this.createDetail()); @@ -69,6 +70,7 @@ export class OtherIncomeComponent implements OnInit { public initOtherincomeForm(): void { this.otherIncomeForm = this.fb.group({ other_income: ['', Validators.compose([Validators.required])], + otherincome_remarks: ['', Validators.compose([Validators.required])], income_details: this.fb.array([]) }); } @@ -108,6 +110,7 @@ export class OtherIncomeComponent implements OnInit { records.formid = this.form_id; records.fk_createdby = this.pdid; records.other_income = this.otherIncomeForm.controls['other_income'].value; + records.otherincome_remarks = this.otherIncomeForm.controls['otherincome_remarks'].value; records.income_details = this.otherIncomeForm.controls['income_details'].value; console.log('data', records); this._pd.saveForm(records).subscribe(data => { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.html new file mode 100644 index 000000000..0ceb4944e --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.html @@ -0,0 +1,81 @@ + +
+ + + +

Raw Materials

+ +

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

Finished Goods

+ +

+
+ + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + +
+
\ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.scss new file mode 100644 index 000000000..db319b869 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.scss @@ -0,0 +1,18 @@ +.address { + display: flex; + padding: 0 2%; + flex-direction: column; +} + +.address > * { + width: 100%; +} +.matcard mat-form-field { + margin: 0 2%; +} +.address .button { + float: right; + width: 10px; + background: #62B013; + color: white; +} \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.ts new file mode 100644 index 000000000..6a89f87d5 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/stock/stock.component.ts @@ -0,0 +1,151 @@ +import { + Component, + OnInit, + Inject, + Input +} from '@angular/core'; + +import { + FormBuilder, + FormGroup, + Validators, + FormArray, FormControl, +} from '@angular/forms'; + +import { NotifierService } from 'angular-notifier'; + +import { + MatDialog, + MatDialogRef, + MAT_DIALOG_DATA +} from '@angular/material'; +/** Service */ +import { PdTrigerService } from '../../../../../pd-service/pd-triger.service'; +import {ActivatedRoute, Router} from '@angular/router'; +@Component({ + selector: 'app-stock', + templateUrl: './stock.component.html', + styleUrls: ['./stock.component.scss'] +}) +export class StockComponent implements OnInit { + @Input() pdid: number; + @Input() form_id: number; + public stockForm: FormGroup; + private notifier: NotifierService; + + constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute, + private router: Router, + private _pd: PdTrigerService) { + this.notifier = notifier; + } + ngOnInit() { + this.initstockForm(); + let params: any = {}; + params.pd_id = this.pdid; + params.pd_form_id = this.form_id; + this._pd.retriveForm(params).subscribe(value => { + console.log('value', value); + const rawMaterial = this.stockForm.controls['raw_materials']; + const finishedGoods = this.stockForm.controls['finished_goods']; + if (value.status == 200) { + let result = Object.keys(value.records.raw_materials).map(function(key) { + return value.records.raw_materials[key]; + }); + let result_Goods = Object.keys(value.records.finished_goods).map(function(key) { + return value.records.finished_goods[key]; + }); + this.stockForm.controls['stock_remarks'].setValue(value.records.stock_remarks); + if (result.length > 0) { + result.forEach(val => { + rawMaterial.push(this.createRawmaterial()); + }); + this.stockForm.controls['raw_materials'].setValue(result); + } else { + rawMaterial.push(this.createRawmaterial()); + } + if (result_Goods.length > 0) { + result_Goods.forEach(val => { + finishedGoods.push(this.createGoods()); + }); + this.stockForm.controls['finished_goods'].setValue(result_Goods); + } else { + finishedGoods.push(this.createGoods()); + } + } else { + rawMaterial.push(this.createRawmaterial()); + finishedGoods.push(this.createGoods()); + } + }) + } + public initstockForm(): void { + this.stockForm = this.fb.group({ + stock_remarks: ['', Validators.compose([Validators.required])], + raw_materials: this.fb.array([]), + finished_goods: this.fb.array([]) + }); + } + createRawmaterial() { + return this.fb.group({ + raw_name: ['', Validators.compose([Validators.required])], + raw_quantity: ['', Validators.compose([Validators.required])], + raw_value: ['', Validators.compose([Validators.required])], + rawmaterial_value: ['', Validators.compose([Validators.required])], + is_sufficiant_raw: ['', Validators.compose([Validators.required])], + }); + } + createGoods() { + return this.fb.group({ + goods_name: ['', Validators.compose([Validators.required])], + goods_quantity: ['', Validators.compose([Validators.required])], + goods_value: ['', Validators.compose([Validators.required])], + finished_goods_value: ['', Validators.compose([Validators.required])], + is_sufficiant_goods: ['', Validators.compose([Validators.required])], + }); + } + addRawMaterials() { + const control = this.stockForm.controls['raw_materials']; + control.push(this.createRawmaterial()); + } + deleteRawMaterials(index) { + const control = this.stockForm.controls['raw_materials']; + control.removeAt(index); + } + addGoods() { + const control = this.stockForm.controls['finished_goods']; + control.push(this.createGoods()); + } + deleteGoods(index) { + const control = this.stockForm.controls['finished_goods']; + control.removeAt(index); + } + submitDetails() { + if (!this.stockForm.valid) { + this.validateAllFormFields(this.stockForm); + return; + } + let records: any = {}; + records.pdid = this.pdid; + records.formid = this.form_id; + records.fk_createdby = this.pdid; + records.raw_materials = this.stockForm.controls['raw_materials'].value; + records.stock_remarks = this.stockForm.controls['stock_remarks'].value; + records.finished_goods = this.stockForm.controls['finished_goods'].value; + console.log('data', records); + this._pd.saveForm(records).subscribe(data => { + console.log('data', data); + this.notifier.notify('success', 'Saved Successfully.'); + }, error => { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + }) + } + validateAllFormFields(formGroup: FormGroup) { + Object.keys(formGroup.controls).forEach(field => { + const control = formGroup.get(field); + if (control instanceof FormControl) { + control.markAsTouched({onlySelf: true}); + } else if (control instanceof FormGroup) { + this.validateAllFormFields(control); + } + }); + } +} diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.html index dcd846977..ef86c6b67 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.html @@ -410,6 +410,22 @@ + + + + + + + + + + + + + + + + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.ts index 8581ad68b..ffff61e10 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.ts @@ -43,7 +43,7 @@ export class StartPdComponent implements OnInit, OnDestroy { // getQuestionsLength:number; // answerList:any=[]; // ansPDList:any=[]; -// pdFullDetails:any=[]; + pdFullDetails:any=[]; // category static form buttons categoryFormButtons: any = [ @@ -87,7 +87,22 @@ export class StartPdComponent implements OnInit, OnDestroy { "form_id": 10, "form_name": "Loan Details", }, - + { + "form_id": 11, + "form_name": "Stock", + }, + { + "form_id": 12, + "form_name": "Employmet Info", + }, + { + "form_id": 13, + "form_name": "Business Info", + }, + { + "form_id": 14, + "form_name": "Financial Info", + }, ]; formsCategoryEnable: boolean = false; selectedFormsCategory: any; @@ -152,28 +167,28 @@ export class StartPdComponent implements OnInit, OnDestroy { } // load pd template details - loadTemplates(startID: string) { - this._pd.loadPDTemplates(startID).subscribe( - data => { - if (data.status == 200) { - this.pdMasterList = data.records.pdmaster_details; - this.categoryList = data.records.question_answers; - let filterApplicantName = data.records.pdapplicants_detials.filter(item => item.applicant_type == 1); - this.mainApplicantName = filterApplicantName[0].applicant_name; - this.currentPDStatus = data.records.pdmaster_details.pd_status; - - this.actualQuestions = data.records.counts.overall_question_count; - this.answeredQuestions = data.records.counts.overall_answered_count; - - } - else { - this.pdMasterList = ""; - this.mainApplicantName = ""; - this.categoryList = []; - this.currentPDStatus = ""; - } - }, error => this.errorMessage = error); - } +// loadTemplates(startID: string) { +// this._pd.loadPDTemplates(startID).subscribe( +// data => { +// if (data.status == 200) { +// this.pdMasterList = data.records.pdmaster_details; +// this.categoryList = data.records.question_answers; +// let filterApplicantName = data.records.pdapplicants_detials.filter(item => item.applicant_type == 1); +// this.mainApplicantName = filterApplicantName[0].applicant_name; +// this.currentPDStatus = data.records.pdmaster_details.pd_status; +// +// this.actualQuestions = data.records.counts.overall_question_count; +// this.answeredQuestions = data.records.counts.overall_answered_count; +// +// } +// else { +// this.pdMasterList = ""; +// this.mainApplicantName = ""; +// this.categoryList = []; +// this.currentPDStatus = ""; +// } +// }, error => this.errorMessage = error); +// } ngOnDestroy(): void { this.listPDComponent.showListView(true); @@ -198,32 +213,32 @@ export class StartPdComponent implements OnInit, OnDestroy { } } - // loadTemplates(startID:string){ - // this._pd.loadPDTemplates(startID).subscribe( - // data => { - // if (data.status == 200) { - // this.pdMasterList=data.records.pdmaster_details; - // this.categoryList=data.records.question_answers; - // let filterApplicantName= data.records.pdapplicants_detials.filter(item => item.applicant_type == 1); - // this.mainApplicantName = filterApplicantName[0].applicant_name; - // this.currentPDStatus = data.records.pdmaster_details.pd_status; - // - // this.actualQuestions = data.records.counts.overall_question_count; - // this.answeredQuestions = data.records.counts.overall_answered_count; - // - // this.pdFullDetails = data.records - // - // } - // else{ - // this.pdMasterList=""; - // this.mainApplicantName=""; - // this.categoryList=[]; - // this.currentPDStatus=""; - // } - // this.getAnswers(serachQuestions); - // - // }); - // } + loadTemplates(startID:string){ + this._pd.loadPDTemplates(startID).subscribe( + data => { + if (data.status == 200) { + this.pdMasterList=data.records.pdmaster_details; + this.categoryList=data.records.question_answers; + let filterApplicantName= data.records.pdapplicants_detials.filter(item => item.applicant_type == 1); + this.mainApplicantName = filterApplicantName[0].applicant_name; + this.currentPDStatus = data.records.pdmaster_details.pd_status; + + this.actualQuestions = data.records.counts.overall_question_count; + this.answeredQuestions = data.records.counts.overall_answered_count; + + this.pdFullDetails = data.records + + } + else{ + this.pdMasterList = ""; + this.mainApplicantName = ""; + this.categoryList = []; + this.currentPDStatus = ""; + } + // this.getAnswers(serachQuestions); + + }); + } // load question based answer list getAnswers(serachList: any) { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts b/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts index d23e0e2fb..aa37696d8 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts @@ -55,6 +55,10 @@ import { AssetsInfoComponent } from './list-pd/start-pd/forms/assets-info/assets import {AddressComponent} from "./list-pd/start-pd/forms/address/address.component"; import {FamilyDetailsComponent} from "./list-pd/start-pd/forms/family-details/family-details.component"; import {BankingDetailsComponent} from "./list-pd/start-pd/forms/banking-details/banking-details.component"; +import {StockComponent} from "./list-pd/start-pd/forms/stock/stock.component"; +import {EmploymentInfoComponent} from "./list-pd/start-pd/forms/employment-info/employment-info.component"; +import {BusinessInfoComponent} from "./list-pd/start-pd/forms/business-info/business-info.component"; +import {FinancialInfoComponent} from "./list-pd/start-pd/forms/financial-info/financial-info.component"; /** * Custom angular notifier options @@ -128,7 +132,7 @@ const pdCustomNotifierOptions: NotifierOptions = { // AgmCoreModule.forRoot({apiKey: 'AIzaSyBtdO5k6CRntAMJCF-H5uZjTCoSGX95cdk'}), OwlDateTimeModule, // OwlNativeDateTimeModule, // ], - declarations: [BankingDetailsComponent, ListPdComponent, FamilyDetailsComponent, AddressComponent, ManagePdComponent, MapPdViewComponent, AddPdComponent, ViewPdComponent, PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, InprogressPdComponent, AllPdComponent, ScheduledPdComponent, CompletedPdComponent, QcCompletedPdComponent, ClientInfoComponent, CurrentLoanComponent, AssetsInfoComponent, LoanDetailsComponent, OtherIncomeComponent, SupplierInfoComponent, PersonalInfoComponent], + declarations: [FinancialInfoComponent, BusinessInfoComponent, EmploymentInfoComponent, StockComponent, BankingDetailsComponent, ListPdComponent, FamilyDetailsComponent, AddressComponent, ManagePdComponent, MapPdViewComponent, AddPdComponent, ViewPdComponent, PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, InprogressPdComponent, AllPdComponent, ScheduledPdComponent, CompletedPdComponent, QcCompletedPdComponent, ClientInfoComponent, CurrentLoanComponent, AssetsInfoComponent, LoanDetailsComponent, OtherIncomeComponent, SupplierInfoComponent, PersonalInfoComponent], // exports: [PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, CompletedPdComponent, QcCompletedPdComponent], // providers: [PdTrigerService, GetGeometricLocationService], // entryComponents: [PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent],