diff --git a/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.html b/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.html index dc2b65856..8a13984ef 100644 --- a/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.html +++ b/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.html @@ -1,16 +1,14 @@
-
- -
-

{{pageTitle}}

-
-
- + + +
+

{{pageTitle}}

+
+
+ +
-
- - -
@@ -18,7 +16,7 @@ You must Select Entity Type. -
+
@@ -31,164 +29,11 @@ You must Include Short Name.
- -
- - - {{ reg.region_name }} - - You must Select Region. - - - - - {{ st.state_name }} - - You must Select State. - - - - - {{ ct.city_name }} - - You must Select City. - - - - - {{ brn.branch_name }} - - You must Select Branch. - - -
- -
- - - You must Include Address. - - - - - - - - - - - - You must Include Pincode. - -
- -
- - - - You must Include Official Email. - - - - - - - - - - You must Include Phone Number. - - - - - - -
- -
- - - You must Include Remarks. - -
-
- -

{{subTitle1}}

-
- - - You must Include Pan Number. - - - - - You must Include GST Number. - - - - You must Include GST State Code. - - - - - You must Include TAT. - -
-
- -
-

{{subTitle2}}

-
-
-
-
-
- -
- - - - - - - - - - - - - -
- -
-
- - - -
-
-
-
- - -
-
- - -
- -
-
- + +
- - \ No newline at end of file diff --git a/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.ts b/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.ts index 899778a06..103a7af08 100644 --- a/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.ts +++ b/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.ts @@ -16,11 +16,12 @@ import { 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 { MastersService } from './../../service/masters/masters.service'; import { EntityService } from './../../service/entity/entity.service'; @@ -41,10 +42,7 @@ export class EntityAddComponent implements OnInit { public subTitle2: string = "Contacts"; public _addQuesFrom: FormGroup; public submitted = false; - public categories: any = []; - public geoRecords: any = []; public entityOptions: any = []; - public questionsOptions: any = []; errorMessage: string; /** @@ -57,7 +55,8 @@ export class EntityAddComponent implements OnInit { private _formBuilder: FormBuilder, private masterService: MastersService, private entityService: EntityService, - private router: Router) { + private router: Router, + private dialogRef: MatDialogRef) { this.notifier = notifier; } @@ -65,96 +64,20 @@ export class EntityAddComponent implements OnInit { ngOnInit() { /** Questions Form Datas*/ this._addQuesFrom = this._formBuilder.group({ + entity_id: [null], fk_entity_type_id: [null, Validators.compose([Validators.required])], full_name: [null, Validators.compose([Validators.required])], short_name: [null, Validators.compose([Validators.required])], - fk_region: [null, Validators.compose([Validators.required])], - fk_state: [null, Validators.compose([Validators.required])], - fk_city: [null, Validators.compose([Validators.required])], - fk_branch: [null, Validators.compose([Validators.required])], - addressline1: [null, Validators.compose([Validators.required])], - pincode: [null, Validators.compose([Validators.required])], - official_email: [null, Validators.compose([Validators.required, Validators.email])], - phone_number: [null, Validators.compose([Validators.required])], - remarks: [null, Validators.compose([Validators.required])], - pan: [null, Validators.compose([Validators.required])], - gst_no: [null, Validators.compose([Validators.required])], - gst_state_code: [null, Validators.compose([Validators.required])], - tat: [null, Validators.compose([Validators.required])], - entity_child: this._formBuilder.array([ - this.initAnswers(), - ]) + remarks: [null], + isactive: [1] }); - // OnInit Load Geo Details and Question Type Masters - this.getGeoLocationMaster(); this.getEntityOptionsMaster(); } // convenience getter for easy access to form fields get f() { return this._addQuesFrom.controls; } - // Dynamic Form field creation Functionality : START ===> - initAnswers() { - return this._formBuilder.group({ - contact_person: ['', Validators.compose([Validators.required])], - contact_email: ['', Validators.compose([Validators.required, Validators.email])], - contact_mobile_no: ['', Validators.compose([Validators.required])], - }); - } - addLanguage(e) { - const control = this._addQuesFrom.controls['entity_child']; - control.push(this.initAnswers()); - } - removeLanguage(i: number) { - const control = this._addQuesFrom.controls['entity_child']; - control.removeAt(i); - } - // END ===> - - public state_m: any = []; - selectGeoRegionChanges(reg){ - this._addQuesFrom.controls.fk_state.reset(); - this._addQuesFrom.controls.fk_city.reset(); - this._addQuesFrom.controls.fk_branch.reset(); - this.state_m = []; - this.city_m = []; - this.branch_m = []; - if(reg){ - this.state_m = reg; - } - } - - public city_m: any = [] - selectGeoStateChanges(city) { - this._addQuesFrom.controls.fk_city.reset(); - this._addQuesFrom.controls.fk_branch.reset(); - this.city_m = []; - this.branch_m = []; - if(city){ - this.city_m = city; - } - } - public branch_m: any = []; - selectGeoCityChanges(brn){ - this._addQuesFrom.controls.fk_branch.reset(); - this.branch_m = []; - if(brn){ - this.branch_m = brn; - } - } - - getGeoLocationMaster() { - this.entityService.getGeoLocationMasterDetails().subscribe( - data => { - this.geoRecords = data.records; - }, - error => { - this.notifier.notify('warning', 'No Geo Location Records Found.!'); - this.errorMessage = "No Category Records Found."; - } - ) - } getEntityOptionsMaster() { this.masterService.getAllMasterData('ENTITYTYPE').subscribe( data => { @@ -169,8 +92,8 @@ export class EntityAddComponent implements OnInit { /** For Popup Close Button */ onNoClick(): void { - // this.dialogRef.close(); - this.router.navigate(['/setting/entity/list']); + this.dialogRef.close(null); + // this.router.navigate(['/setting/entity/list']); } /** To Save/Edited Popup Data */ @@ -192,16 +115,16 @@ export class EntityAddComponent implements OnInit { if (dataresult.status == 200) { console.log(dataresult); this.notifier.notify('success', 'Record Saved Successfully.!'); - this.router.navigate(['/setting/entity/list']); - this._addQuesFrom.reset(); + this.dialogRef.close(dataresult); } else { this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); - this.errorMessage = "Some Thing Wents Wrong Try Again !"; + // this.errorMessage = "Some Thing Wents Wrong Try Again !"; } }, error => { + this.dialogRef.close(null); this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); - this.errorMessage = "Something Wents Wrong Try Again !"; + // this.errorMessage = "Something Wents Wrong Try Again !"; }); } } diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-billing-info/dialog-add-edit-billing-info.component.html b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-billing-info/dialog-add-edit-billing-info.component.html new file mode 100644 index 000000000..de197c7cd --- /dev/null +++ b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-billing-info/dialog-add-edit-billing-info.component.html @@ -0,0 +1,103 @@ +
+
+ +
+ +

{{editAddType}} - Billing Information Details

+
+ +
+
+ + + You must Include Billing Name. + +
+
+ + + You must Include Door No./ Street No. + + + + + You must Include Street Name. + + + + + You must Include City, State. + + + + + You must Include Pincode. + +
+ +
+ + + You must Include Email. + + + + + You must Include Mobile. + +
+ +
+ + + You must Include GST. + + + + + You must Include PAN. + +
+ +
+
+
+
+
+ + + You must Include Person Name. + + + + + You must Include Contact Person Mobile. + + + + + You must Include Contact Person Email. + +
+
+
+ + +
+
+ +
+ + +
+
+
+ +
\ No newline at end of file diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-billing-info/entity-edit-billing-info.component.html b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-billing-info/entity-edit-billing-info.component.html index 16157a9cb..1cc230026 100644 --- a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-billing-info/entity-edit-billing-info.component.html +++ b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-billing-info/entity-edit-billing-info.component.html @@ -1,6 +1,24 @@ -

- entity-edit-billing-info works! - -

- -

{{ entityId }}

+
+ +
+ +
+
+ {{data.billing_name}} +
+
+
+ {{data.addressline2}}, {{data.addressline3}} +
+
+ Pan: {{data.pan}}, Gst: {{data.gstno}} +
+
+ Contact Person Info, Contact Person Info, Contact Person Info +
+
+
+ +
+
+
\ No newline at end of file diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-billing-info/entity-edit-billing-info.component.ts b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-billing-info/entity-edit-billing-info.component.ts index 79c7bedc9..bfabea685 100644 --- a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-billing-info/entity-edit-billing-info.component.ts +++ b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-billing-info/entity-edit-billing-info.component.ts @@ -1,4 +1,14 @@ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, ViewChild, OnInit, OnDestroy, Input, Inject } from '@angular/core'; +import { MatPaginator, MatSort, MatTableDataSource, MatDialog, MatDialogRef, MAT_DIALOG_DATA, PageEvent } from '@angular/material'; +import { FormGroup, FormControl, FormBuilder, Validators, FormArray } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; + +import { NotifierService } from 'angular-notifier'; + +import { MastersService } from './../../../service/masters/masters.service'; +import { EntityService } from './../../../service/entity/entity.service'; @Component({ selector: 'app-entity-edit-billing-info', @@ -7,10 +17,224 @@ import { Component, OnInit, Input } from '@angular/core'; }) export class EntityEditBillingInfoComponent implements OnInit { - @Input() entityId: number; - constructor() { } + @Input() public entityId: number; + + public entityBillingInfoRecord: any; + public noRecordFound: boolean; + constructor(private dialog: MatDialog, + private entityService: EntityService) { } ngOnInit() { + this.getEntityIDBillingInfo(); + } + + getEntityIDBillingInfo() { + this.entityService.getEntityIdBillingInfoDetails(this.entityId).subscribe( + data => { + if (data) { + if (data.records) { + this.noRecordFound = false; + this.entityBillingInfoRecord = data.records; + } else { + this.noRecordFound = true; + } + } else { + this.noRecordFound = true; + } + } + ); + } + + editDetails(rowDetails: any) { + const dialogRef = this.dialog.open(DialogAddEditBillingInfo, { + data: {'details':rowDetails, entity_id: this.entityId}, + disableClose: true + }); + dialogRef.afterClosed() + .subscribe(dataresult => { + this.getEntityIDBillingInfo(); + }); + } + +} + + +@Component({ + selector: 'dialog-add-edd-billing-info', + styles: [`` + ], + templateUrl: './dialog-add-edit-billing-info.component.html' +}) +export class DialogAddEditBillingInfo implements OnInit { + + public m_questions: any; + public editAddType = 'Edit'; + public _editEntityBillingInfoFrom: FormGroup; + errorRecord: string; + noRecordFound: boolean; + public submitted: boolean; + + /** + * Notifier service + */ + private notifier: NotifierService; + constructor( + notifier: NotifierService, + private route: ActivatedRoute, + private router: Router, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any, + private entityService: EntityService, + private mastersService: MastersService, + private _formBuilder: FormBuilder) { + // this.entity_id = this.route.snapshot.params['entity-id']; + // this.entity_id = this.parent.entityId; + this.notifier = notifier; + } + + ngOnInit(): void { + this.loadFormData(); + this.loadContactsDetails(this.data.details.contacts); + } + + onNoClick(): void { + this.dialogRef.close(); + } + + + // load form data form the master + loadFormData() { + /** Questions Form Datas*/ + if(this.data.details == null) { + this._editEntityBillingInfoFrom = this._formBuilder.group({ + entity_billing_id: [''], + fk_entity_id: [this.data.entity_id], + billing_name: ['', Validators.compose([Validators.required])], + addressline1: ['', Validators.compose([Validators.required])], + addressline2: ['', Validators.compose([Validators.required])], + addressline3: ['', Validators.compose([Validators.required])], + pincode: ['', Validators.compose([Validators.required])], + email: ['', Validators.compose([Validators.required])], + mobileno: ['', Validators.compose([Validators.required])], + gstno: ['', Validators.compose([Validators.required])], + gststatecode: [''], + pan: ['', Validators.compose([Validators.required])], + contacts: this._formBuilder.array([ + this.initContacts(null) + ]) + }); + } else { + let data = this.data.details; + this._editEntityBillingInfoFrom = this._formBuilder.group({ + entity_billing_id: [data.entity_billing_id], + fk_entity_id: [data.fk_entity_id], + billing_name: [data.billing_name, Validators.compose([Validators.required])], + addressline1: [data.addressline1, Validators.compose([Validators.required])], + addressline2: [data.addressline2, Validators.compose([Validators.required])], + addressline3: [data.addressline3, Validators.compose([Validators.required])], + pincode: [data.pincode, Validators.compose([Validators.required])], + email: [data.email, Validators.compose([Validators.required])], + mobileno: [data.mobileno, Validators.compose([Validators.required])], + gstno: [data.gstno, Validators.compose([Validators.required])], + gststatecode: [data.gststatecode], + pan: [data.pan, Validators.compose([Validators.required])], + contacts: this._formBuilder.array([ + ]) + }); + } + + } + + loadContactsDetails(record: any) { + if(record == null || record == undefined){ + this.addContacts(null); + } else { + if(record.length > 0) { + for (let val of record) { + let vals = val; + this.addContacts(vals); + } + } + } + } + + // convenience getter for easy access to form fields + get f() { return this._editEntityBillingInfoFrom.controls; } + + // form contacts details access + get f_contacts() { return this._editEntityBillingInfoFrom.get('contacts'); } + + + // Dynamic Form field creation Functionality : START ===> + initContacts(conts) { + if(conts == null){ + return this._formBuilder.group({ + entity_billing_contact_id: [null], + fk_entity_billing_id: [null], + contact_person: ['', Validators.compose([Validators.required])], + contact_email: ['', Validators.compose([Validators.required])], + contact_mobile_no: ['', Validators.compose([Validators.required])], + isactive: [1] + }); + } else { + return this._formBuilder.group({ + entity_billing_contact_id: [conts.entity_billing_contact_id], + fk_entity_billing_id: [conts.fk_entity_billing_id], + contact_person: [conts.contact_person, Validators.compose([Validators.required])], + contact_email: [conts.contact_email, Validators.compose([Validators.required])], + contact_mobile_no: [conts.contact_mobile_no, Validators.compose([Validators.required])], + isactive: [conts.isactive] + }); + } + } + + addContacts(conts) { + const control = this._editEntityBillingInfoFrom.controls['contacts']; + control.push(this.initContacts(conts)); + } + + removeContacts(i: number) { + const control = this._editEntityBillingInfoFrom.controls['contacts']; + control.removeAt(i); + } + + // END ===> + + + /** To Save/Edited Popup Data */ + onSubmit() { + this.submitted = true; + // stop here if form is invalid + if (this._editEntityBillingInfoFrom.invalid) { + // this.errorMessage = "Please Fill All Mandate Fields."; + return; + } else { + var billingInfoFormValues = this._editEntityBillingInfoFrom.value; + + //To Remove The "Null" With Key also + Object.keys(billingInfoFormValues).forEach((key) => (billingInfoFormValues[key] == null) && delete billingInfoFormValues[key]); + alert(billingInfoFormValues); + this.entityService.updateEntityIdBillingInfoDetails(billingInfoFormValues).subscribe( + dataresult => { + if (dataresult.status == 200) { + console.log(dataresult); + this.notifier.notify('success', 'Your Changes Updated.!'); + this.dialogRef.close(); + } + else { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + } + }, error => { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + this.dialogRef.close(); + }); + } + } + + /** To Reset Popup Data */ + onReset() { + this.loadFormData(); + this.loadContactsDetails(this.data.details.contacts); } } diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-region/entity-edit-region.component.html b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-region/entity-edit-region.component.html index 5b1bea794..f80cb252e 100644 --- a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-region/entity-edit-region.component.html +++ b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-region/entity-edit-region.component.html @@ -1,3 +1,51 @@ -

- entity-edit-region works! -

+
+
+ +
+
+ + + {{ reg.name }} + + Region Required.! + + + + + {{ city.city_name }}({{city.state_name}}) + + City Required.! + + + + +
+ + + + + +
+
+
+
+ +
+
+ + +
+
diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-region/entity-edit-region.component.ts b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-region/entity-edit-region.component.ts index 689d0f944..e08d6000e 100644 --- a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-region/entity-edit-region.component.ts +++ b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-region/entity-edit-region.component.ts @@ -1,4 +1,14 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, ViewChild, OnInit, OnDestroy, Input, Inject } from '@angular/core'; +import { MatPaginator, MatSort, MatTableDataSource, MatDialog, MatDialogRef, MAT_DIALOG_DATA, PageEvent } from '@angular/material'; +import { FormGroup, FormControl, FormBuilder, Validators, FormArray } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; + +import { NotifierService } from 'angular-notifier'; + +import { MastersService } from './../../../service/masters/masters.service'; +import { EntityService } from './../../../service/entity/entity.service'; @Component({ selector: 'app-entity-edit-region', @@ -7,9 +17,213 @@ import { Component, OnInit } from '@angular/core'; }) export class EntityEditRegionComponent implements OnInit { - constructor() { } + @Input() public entityId: number; + + public noRocordsFound: boolean; + public entityRegionRecord: any; + public errorMessage; + + public m_region: any = []; + public m_city: any = []; + public m_state: any = []; + public m_branch: any = []; + + public _editEntityRegionFrom: FormGroup; + public submitted = false; + + + /** + * Notifier service + */ + private notifier: NotifierService; + + constructor( + notifier: NotifierService, + private entityService: EntityService, + private mastersService: MastersService, + private _formBuilder: FormBuilder) { + this.notifier = notifier; + } ngOnInit() { + this.getEntityIDRegionInfoDetails(); + this.getCityHierarchyMaster(); + this.getRegionMasters(); + // this.getCustomerSegmentMasters(); + + this._editEntityRegionFrom = this._formBuilder.group({ + region_lender: this._formBuilder.array([ + // this.addRegionFormData(null, null), + ]) + }) + // this.addRegionFormData(null, null); + } + + setFormDatas(record) { + if (record.length > 0) { + for (let val of record) { + let vals = { + entity_region_map_id: val.entity_region_map_id, + fk_entity_id: val.fk_entity_id, + fk_region_id: val.fk_region_id, + fk_city_id: val.fk_city_id, + // fk_state_id: null, + // fk_branch_id: null, + isactive: val.isactive, + }; + this.addRegionFormData(vals, null); + } + } + } + + getEntityIDRegionInfoDetails() { + this.entityService.getEntityIdRegionInfoDetails(this.entityId).subscribe( + data => { + if (data) { + if (data.records) { + this.noRocordsFound = false; + this.entityRegionRecord = data.records; + this.setFormDatas(this.entityRegionRecord); + } else { + this.noRocordsFound = true; + } + } else { + this.noRocordsFound = true; + } + } + ); + } + + getCityHierarchyMaster() { + this.entityService.getCityHierarchyMaster().subscribe( + data => { + this.m_city = data.records; + }, + error => { + this.notifier.notify('warning', 'No City Master Records Found.!'); + // this.errorMessage = "No Lender Master Record Found."; + } + ); + } + + getRegionMasters() { + this.mastersService.getAllMasterData('REGIONS').subscribe( + data => { + this.m_region = data.records; + }, + error => { + this.notifier.notify('warning', 'No Region Master Records Found.!'); + // this.errorMessage = "No Region Master Record Found."; + } + ); + } + + // getCustomerSegmentMasters() { + // this.templatesService.getCustomerSegmentsMasterListDetails().subscribe( + // data => { + // this.m_customerSegment = data.records; + // }, + // error => { + // this.notifier.notify('warning', 'No Customer Segment Master Records Found.!'); + // this.errorMessage = "No Customer Segment Master Record Found."; + // } + // ); + // } + + // convenience getter for easy access to form fields + get f() { return this._editEntityRegionFrom.controls; } + + // Dynamic Form field creation Functionality : START ===> + initRegionFormLoad(data) { + return this._formBuilder.group({ + entity_region_map_id: [data.entity_region_map_id], + fk_entity_id: [data.fk_entity_id], + fk_region_id: [data.fk_region_id, Validators.compose([Validators.required])], + fk_city_id: [data.fk_city_id, Validators.compose([Validators.required])], + // fk_state_id: [data.fk_state_id, Validators.compose([Validators.required])], + // fk_branch_id: [data.fk_branch_id, Validators.compose([Validators.required])], + isactive: [data.isactive], + }); + } + addRegionFormData(data, e) { + if (data == null) { + let newDate = { + entity_region_map_id: null, + fk_entity_id: this.entityId, + fk_region_id: null, + fk_city_id: null, + // fk_state_id: null, + // fk_branch_id: null, + isactive: 1, + } + const control = this._editEntityRegionFrom.controls['region_lender']; + control.push(this.initRegionFormLoad(newDate)); + } else { + const control = this._editEntityRegionFrom.controls['region_lender']; + control.push(this.initRegionFormLoad(data)); + } + } + removeLanguage(i: number) { + const control = this._editEntityRegionFrom.controls['region_lender']; + control.removeAt(i); + } + + // END ===> + + /** To Save/Edited Popup Data */ + onSubmit() { + this.submitted = true; + // stop here if form is invalid + if (this._editEntityRegionFrom.invalid) { + this.errorMessage = "Please Fill All Mandate Fields."; + return; + } else { + var formValues = this._editEntityRegionFrom.value; + //To Remove The "Null" With Key also + Object.keys(formValues).forEach((key) => (formValues[key] == null) && delete formValues[key]); + // alert(JSON.stringify(formValues.temp_lender)); + if (!this.checkDuplicateInObject(formValues.region_lender)) { + this.entityService.updateEntityIdRegionInfoDetails(formValues.region_lender).subscribe( + dataresult => { + if (dataresult.status == 200) { + console.log(dataresult); + this.notifier.notify('success', 'Your Changes Updated.!'); + const arr = this._editEntityRegionFrom.controls.region_lender; + arr.controls.splice(0); + this.getEntityIDRegionInfoDetails(); + } + else { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + this.errorMessage = "Something Wents Wrong Try Again.!"; + } + }, error => { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + this.errorMessage = "Some Thing Wents Wrong Try Again.!"; + }); + } else { + this.notifier.notify('warning', 'duplication records occured.!'); + } + } + } + + + checkDuplicateInObject(inputArray) { + let seenDuplicate = false; + inputArray.map(function (item, index) { + let currentVal = inputArray[index]; + for (let i = index + 1; i < inputArray.length; i++) { + if (currentVal.fk_region_id === inputArray[i].fk_region_id + && currentVal.fk_city_id === inputArray[i].fk_city_id) { + console.log('duplication: ' + i); + seenDuplicate = true; + } + } + console.log(index); + }); + return seenDuplicate; + } + + ngOnDestroy(): void { } } diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-tat/entity-edit-tat.component.html b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-tat/entity-edit-tat.component.html index 1db862867..6222fc96d 100644 --- a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-tat/entity-edit-tat.component.html +++ b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-tat/entity-edit-tat.component.html @@ -1,3 +1 @@ -

- entity-edit-tat works! -

+

Tat info

\ No newline at end of file diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-tat/entity-edit-tat.component.ts b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-tat/entity-edit-tat.component.ts index a685b4348..ac780819d 100644 --- a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-tat/entity-edit-tat.component.ts +++ b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-tat/entity-edit-tat.component.ts @@ -1,4 +1,14 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, ViewChild, OnInit, OnDestroy, Input, Inject } from '@angular/core'; +import { MatPaginator, MatSort, MatTableDataSource, MatDialog, MatDialogRef, MAT_DIALOG_DATA, PageEvent } from '@angular/material'; +import { FormGroup, FormControl, FormBuilder, Validators, FormArray } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; + +import { NotifierService } from 'angular-notifier'; + +import { MastersService } from './../../../service/masters/masters.service'; +import { EntityService } from './../../../service/entity/entity.service'; @Component({ selector: 'app-entity-edit-tat', @@ -7,9 +17,71 @@ import { Component, OnInit } from '@angular/core'; }) export class EntityEditTatComponent implements OnInit { - constructor() { } + public noRocordsFound: boolean; + public entityVendorCityRecord: any; + public errorMessage; + + @Input() public entityId: number; + public m_city: any = []; + public selectedArr: any = []; + + + toppings1 = new FormControl(); + + toppingList1: any[] = [{'id': 1,'name':'Extra cheese'}, {'id': 2, 'name':'Mushroom'}, { 'id': 3, 'name':'Onion'}]; + + /** + * Notifier service + */ + private notifier: NotifierService; + + constructor(notifier: NotifierService, + private entityService: EntityService, + private mastersService: MastersService, + private _formBuilder: FormBuilder) { + this.notifier = notifier; + } ngOnInit() { + this.getEntityIdCityDetails(); + this.getCityMasters(); + this.toppings1.setValue([3]); + } + + selectedItem: any; + + selected(e){ + this.selectedArr = [...e.value]; + this.selectedItem = this.m_city.filter(val => this.selectedArr.indexOf(val.city_id) > -1) + } + + getEntityIdCityDetails(){ + this.entityService.getEntityIdCityInfoDetails(this.entityId).subscribe( + data => { + if (data) { + if (data.records) { + this.noRocordsFound = false; + this.entityVendorCityRecord = data.records; + } else { + this.noRocordsFound = true; + } + } else { + this.noRocordsFound = true; + } + } + ); + } + + getCityMasters() { + this.mastersService.getAllMasterData('CITY').subscribe( + data => { + this.m_city = data.records; + }, + error => { + this.notifier.notify('warning', 'No City Master Records Found.!'); + // this.errorMessage = "No Region Master Record Found."; + } + ); } } diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-vendor-city-info/entity-edit-vendor-city-info.component.html b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-vendor-city-info/entity-edit-vendor-city-info.component.html new file mode 100644 index 000000000..8034c6fea --- /dev/null +++ b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-vendor-city-info/entity-edit-vendor-city-info.component.html @@ -0,0 +1,17 @@ + + + {{city.name}} + + + + + + + {{cit.name}} + + +
+ + +
diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-vendor-city-info/entity-edit-vendor-city-info.component.scss b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-vendor-city-info/entity-edit-vendor-city-info.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-vendor-city-info/entity-edit-vendor-city-info.component.spec.ts b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-vendor-city-info/entity-edit-vendor-city-info.component.spec.ts new file mode 100644 index 000000000..4ca6f3c20 --- /dev/null +++ b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-vendor-city-info/entity-edit-vendor-city-info.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EntityEditVendorCityInfoComponent } from './entity-edit-vendor-city-info.component'; + +describe('EntityEditVendorCityInfoComponent', () => { + let component: EntityEditVendorCityInfoComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EntityEditVendorCityInfoComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EntityEditVendorCityInfoComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-vendor-city-info/entity-edit-vendor-city-info.component.ts b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-vendor-city-info/entity-edit-vendor-city-info.component.ts new file mode 100644 index 000000000..3027434d1 --- /dev/null +++ b/ng6-seed/src/app/settings/entity/entity-edit/entity-edit-vendor-city-info/entity-edit-vendor-city-info.component.ts @@ -0,0 +1,149 @@ +import { Component, ViewChild, OnInit, OnDestroy, Input, Inject } from '@angular/core'; +import { MatPaginator, MatSort, MatTableDataSource, MatDialog, MatDialogRef, MAT_DIALOG_DATA, PageEvent } from '@angular/material'; +import { FormGroup, FormControl, FormBuilder, Validators, FormArray } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; + +import { NotifierService } from 'angular-notifier'; + +import { MastersService } from './../../../service/masters/masters.service'; +import { EntityService } from './../../../service/entity/entity.service'; + +@Component({ + selector: 'app-entity-edit-vendor-city-info', + templateUrl: './entity-edit-vendor-city-info.component.html', + styleUrls: ['./entity-edit-vendor-city-info.component.scss'] +}) +export class EntityEditVendorCityInfoComponent implements OnInit { + + public noRocordsFound: boolean; + public entityVendorCityRecord: any; + public errorMessage; + + @Input() public entityId: number; + public m_city: any = []; + public selectedArr: any = []; + + + toppings1 = new FormControl(); + + toppingList1: any[] = [{'id': 1,'name':'Extra cheese'}, {'id': 2, 'name':'Mushroom'}, { 'id': 3, 'name':'Onion'}]; + + /** + * Notifier service + */ + private notifier: NotifierService; + + constructor(notifier: NotifierService, + private entityService: EntityService, + private mastersService: MastersService, + private _formBuilder: FormBuilder) { + this.notifier = notifier; + } + + ngOnInit() { + this.getEntityIdCityDetails(); + this.getCityMasters(); + // this.toppings1.setValue(['1']); + } + + selectedItem: any; + + selected(e){ + this.selectedArr = [...e.value]; + this.getNameofCityId(e.value); + // this.selectedItem = this.m_city.filter(val => this.selectedArr.indexOf(val.city_id) > -1) + } + + getEntityIdCityDetails(){ + this.entityService.getEntityIdCityInfoDetails(this.entityId).subscribe( + data => { + if (data) { + if (data.records) { + this.noRocordsFound = false; + if(data.records[0]){ + this.entityVendorCityRecord = data.records[0]; + let arr: string[] = this.entityVendorCityRecord.fk_city_id.split(','); + let arrVal = arr.map(val => val); + this.getNameofCityId(arrVal); + this.toppings1.setValue(arrVal); + } else { + this.toppings1.setValue(null); + } + } else { + this.noRocordsFound = true; + } + } else { + this.noRocordsFound = true; + } + } + ); + } + + selectedCityName:any; + + getNameofCityId(arg) { + let arrs = [...arg]; + this.selectedCityName = this.m_city.filter(val => arrs.indexOf(val.city_id) > -1) + } + + getCityMasters() { + this.mastersService.getAllMasterData('CITY').subscribe( + data => { + this.m_city = data.records; + }, + error => { + this.notifier.notify('warning', 'No City Master Records Found.!'); + // this.errorMessage = "No Region Master Record Found."; + } + ); + } + + onSubmit() { + + let cityArr: any[] = this.toppings1.value; + + if(cityArr.length > 0) { + let Records:any; + if(this.entityVendorCityRecord){ + Records = { + "vendor_city_map_id": this.entityVendorCityRecord.vendor_city_map_id || '', + "fk_vendor_id": this.entityVendorCityRecord.fk_vendor_id || this.entityId, + "fk_city_id": cityArr.toString(), + } + } else { + Records = { + "vendor_city_map_id": '', + "fk_vendor_id": this.entityId, + "fk_city_id": cityArr.toString(), + } + } + this.entityService.updateEntityIdCityInfoDetails(Records).subscribe( + dataresult => { + if (dataresult.status == 200) { + console.log(dataresult); + this.notifier.notify('success', 'Your Changes Updated.!'); + // const arr = this._editEntityRegionFrom.controls.region_lender; + // arr.controls.splice(0); + // this.getEntityIDRegionInfoDetails(); + } + else { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + this.errorMessage = "Something Wents Wrong Try Again.!"; + } + }, error => { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + this.errorMessage = "Some Thing Wents Wrong Try Again.!"; + }); + + }else { + this.notifier.notify('warning', 'City Should Selected.!'); + } + } + + onReset() { + this.getEntityIdCityDetails(); + } + +} diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.html b/ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.html index 32605361c..267cd60f1 100644 --- a/ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.html +++ b/ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.html @@ -178,41 +178,63 @@ --> + - + ---> + + + \ No newline at end of file diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.ts b/ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.ts index d7ae61195..520eaedc3 100644 --- a/ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.ts +++ b/ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.ts @@ -21,6 +21,7 @@ import { NotifierService } from 'angular-notifier'; /** Service */ import { MastersService } from './../../service/masters/masters.service'; import { EntityService } from './../../service/entity/entity.service'; + import { EntityListComponent } from './../entity-list/entity.list.component'; /* * Question master details edit component @@ -29,23 +30,19 @@ import { EntityListComponent } from './../entity-list/entity.list.component'; @Component({ selector: 'app-entity-edit', templateUrl: './entity.edit.component.html', -// styleUrls: ['./edit.component.scss'] + // styleUrls: ['./edit.component.scss'] }) -export class EntityEditComponent implements OnInit, OnDestroy{ +export class EntityEditComponent implements OnInit, OnDestroy { - @Input() public childMessage: any; + @Input() public childMessage: any; -public entity_id: number; -public pageTitle: string = "Entity"; - public subTitle1: string = "Tax Info"; - public subTitle2: string = "Contacts"; - public _addQuesFrom: FormGroup; + public entity_id: number; + public _editEntityNameFrom: FormGroup; public submitted = false; - public categories: any = []; - public geoRecords: any = []; - public entityOptions: any = []; - public questionsOptions: any = []; errorMessage: string; + public noEntityNameFound: boolean; + public entityNameRecord: any; + /** * Notifier service @@ -62,188 +59,78 @@ public pageTitle: string = "Entity"; private entityListComponent: EntityListComponent) { this.notifier = notifier; this.entity_id = this.route.snapshot.params['entity-id']; + this.getEntityIdDetails(); + // this._editEntityNameFrom = this._formBuilder.group({ + // full_name: ['', Validators.compose([Validators.required]) ] + // }) } ngOnInit() { - this.loadFormData(); - /** Questions Form Datas*/ - if (this.childMessage["0"].length > 0) { - for (let val of this.childMessage["0"]) { - // alert(JSON.stringify(val)); - let vals = val; - this.addLanguage(vals['contact_person'], vals['contact_email'], vals['contact_mobile_no'], vals['entity_child_id'], vals['isactive'], null); - } - } - - // OnInit Load Geo Details and Question Type Masters - this.getGeoLocationMaster(); - this.getEntityOptionsMaster(); + this.entityListComponent.showListView(false); } - // load answer details list - loadAnsData() { - if (this.childMessage["0"].length > 0) { - for (let val of this.childMessage["0"]) { - // alert(JSON.stringify(val)); - let vals = val; - this.addLanguage(vals['contact_person'], vals['contact_email'], vals['contact_mobile_no'], vals['entity_child_id'], vals['isactive'], null); - } - } - } - + public localEntityType: number; + + getEntityIdDetails() { + this.entityService.getEntityIdNameDetails(this.entity_id).subscribe( + data => { + if (data) { + if (data.records) { + this.noEntityNameFound = false; + this.entityNameRecord = data.records.data[0]; + this.localEntityType = this.entityNameRecord.fk_entity_type_id; + this.setFormDatas(); + } else { + this.noEntityNameFound = true; + } + } else { + this.noEntityNameFound = true; + } + } + ); + } + + setFormDatas(){ + // alert(this.templateNameDetails.template_name); + this._editEntityNameFrom = this._formBuilder.group({ + entity_id: [this.entityNameRecord.entity_id], + full_name: [this.entityNameRecord.full_name, Validators.compose([Validators.required]) ], + short_name: [this.entityNameRecord.short_name, Validators.compose([Validators.required]) ], + // entity_name: [this.entityNameRecord.entity_name], + fk_entity_type_id: [this.entityNameRecord.fk_entity_type_id], + isactive: [this.entityNameRecord.isactive] + }) + } - loadFormData() { - this._addQuesFrom = this._formBuilder.group({ - entity_id: [this.childMessage.entity_id], - fk_entity_type_id: [this.childMessage.fk_entity_type_id, Validators.compose([Validators.required])], - full_name: [this.childMessage.full_name, Validators.compose([Validators.required])], - short_name: [this.childMessage.short_name, Validators.compose([Validators.required])], - fk_region: [this.childMessage.fk_region, Validators.compose([Validators.required])], - fk_state: [this.childMessage.fk_state, Validators.compose([Validators.required])], - fk_city: [this.childMessage.fk_city, Validators.compose([Validators.required])], - fk_branch: [this.childMessage.fk_branch, Validators.compose([Validators.required])], - addressline1: [this.childMessage.addressline1, Validators.compose([Validators.required])], - pincode: [this.childMessage.pincode, Validators.compose([Validators.required])], - official_email: [this.childMessage.official_email, Validators.compose([Validators.required, Validators.email])], - phone_number: [this.childMessage.phone_number, Validators.compose([Validators.required])], - remarks: [this.childMessage.remarks, Validators.compose([Validators.required])], - pan: [this.childMessage.pan, Validators.compose([Validators.required])], - gst_no: [this.childMessage.gst_no, Validators.compose([Validators.required])], - gst_state_code: [this.childMessage.gst_state_code, Validators.compose([Validators.required])], - tat: [this.childMessage.tat, Validators.compose([Validators.required])], - entity_child: this._formBuilder.array([ - // this.initAnswers(), - ]) - }); - } // convenience getter for easy access to form fields - get f() { return this._addQuesFrom.controls; } + get f() { return this._editEntityNameFrom.controls; } -// form entity_child details access - get f_ans() { return this._addQuesFrom.get('entity_child'); } - // Dynamic Form field creation Functionality : START ===> - initAnswers(c_person, c_email, e_phn, fk_id, isAct, e) { - isAct = isAct == null ? 1 : isAct; - return this._formBuilder.group({ - contact_person: [c_person, Validators.compose([Validators.required])], - contact_email: [c_email, Validators.compose([Validators.required, Validators.email])], - contact_mobile_no: [e_phn, Validators.compose([Validators.required])], - entity_child_id: [fk_id], - isactive: [isAct] - }); - } - addLanguage(c_person, c_email, e_phn, fk_id, isAct, e) { - const control = this._addQuesFrom.controls['entity_child']; - control.push(this.initAnswers(c_person, c_email, e_phn, fk_id, isAct, e)); - } - removeLanguage(i: number) { - const control = this._addQuesFrom.controls['entity_child']; - control.removeAt(i); - } - - // END ===> - - public state_m: any = []; - selectGeoRegionChanges(reg){ - this._addQuesFrom.controls.fk_state.reset(); - this._addQuesFrom.controls.fk_city.reset(); - this._addQuesFrom.controls.fk_branch.reset(); - this.state_m = []; - this.city_m = []; - this.branch_m = []; - if(reg){ - this.state_m = reg; - } - } - - public city_m: any = [] - selectGeoStateChanges(city) { - this._addQuesFrom.controls.fk_city.reset(); - this._addQuesFrom.controls.fk_branch.reset(); - this.city_m = []; - this.branch_m = []; - if(city){ - this.city_m = city; - } - } - public branch_m: any = []; - selectGeoCityChanges(brn){ - this._addQuesFrom.controls.fk_branch.reset(); - this.branch_m = []; - if(brn){ - this.branch_m = brn; - } - } - - getGeoLocationMaster() { - this.entityService.getGeoLocationMasterDetails().subscribe( - data => { - this.geoRecords = data.records; - this.setGeoEditSelectDetails(); - }, - error => { - this.notifier.notify('warning', 'No Geo Location Records Found.!'); - this.errorMessage = "No Category Records Found."; - } - ) - } - - setGeoEditSelectDetails() { - let state = this.geoRecords.filter(data=>{if(data.region_id === this.childMessage.fk_region){ return data.state_data;}}); - this.state_m = state[0].state_data; - let city = this.state_m.filter(data=>{if(data.state_id === this.childMessage.fk_state){ return data.city_data;}}); - this.city_m = city[0].city_data; - let branch = this.city_m.filter(data=>{if(data.city_id === this.childMessage.fk_city){ return data.branch_data;}}); - // alert(JSON.stringify(branch)); - this.branch_m = branch[0].branch_data; - } - getEntityOptionsMaster() { - this.masterService.getAllMasterData('ENTITYTYPE').subscribe( - data => { - this.entityOptions = data.records.filter(data => data.entity_type_id != 1); - }, - error => { - this.notifier.notify('warning', 'No Answer Type Records Found.!'); - this.errorMessage = "No Answer Type Record Found."; - } - ) - } - - /** For Popup Close Button */ - onNoClick(): void { - this.entityListComponent.changeListView(); - // this.dialogRef.close(); - } - - backToList(){ + backToList() { this.entityListComponent.showListView(true); - this.router.navigate([ '../../' ], { relativeTo: this.route }); + this.router.navigate(['../../'], { relativeTo: this.route }); } /** To Save/Edited Popup Data */ onSubmit() { this.submitted = true; // stop here if form is invalid - if (this._addQuesFrom.invalid) { + if (this._editEntityNameFrom.invalid) { this.errorMessage = "Please Fill All Mandate Fields."; return; } else { - var entityFormValues = this._addQuesFrom.value; + var entityFormValues = this._editEntityNameFrom.value; - //To Remove The "Null" With Key also Object.keys(entityFormValues).forEach((key) => (entityFormValues[key] == null) && delete entityFormValues[key]); - //Add BRANCH data with help Service File this.entityService.updateEntityMasterDetails(entityFormValues).subscribe( dataresult => { if (dataresult.status == 200) { console.log(dataresult); this.notifier.notify('success', 'Record Updated Successfully.!'); - this._addQuesFrom.reset(); - this.entityListComponent.changeListView(); + this.getEntityIdDetails(); } else { this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); @@ -258,8 +145,7 @@ public pageTitle: string = "Entity"; /** To Reset Popup Data */ onReset() { - this.loadFormData(); - this.loadAnsData(); + this.getEntityIdDetails(); } ngOnDestroy(): void { diff --git a/ng6-seed/src/app/settings/entity/entity-list/entity.list.component.html b/ng6-seed/src/app/settings/entity/entity-list/entity.list.component.html index 1c62c2af2..355e784e1 100644 --- a/ng6-seed/src/app/settings/entity/entity-list/entity.list.component.html +++ b/ng6-seed/src/app/settings/entity/entity-list/entity.list.component.html @@ -8,7 +8,7 @@
- +
@@ -50,14 +50,9 @@ -
- -
- -
- +
\ No newline at end of file diff --git a/ng6-seed/src/app/settings/entity/entity-list/entity.list.component.ts b/ng6-seed/src/app/settings/entity/entity-list/entity.list.component.ts index fd02b8785..3f3bf6917 100644 --- a/ng6-seed/src/app/settings/entity/entity-list/entity.list.component.ts +++ b/ng6-seed/src/app/settings/entity/entity-list/entity.list.component.ts @@ -133,13 +133,14 @@ export class EntityListComponent implements OnInit { public parentMessage: any = []; editEntity(detail){ this.parentMessage = detail; + this.router.navigate([ '../list/edit', detail.entity_id ], { relativeTo: this.route }); this.listView = false; } - goToEdit(template_id : number){ - this.router.navigate([ '../list/edit', template_id ], { relativeTo: this.route }); - this.listView = false; - } + // goToEdit(template_id : number){ + // this.router.navigate([ '../list/edit', template_id ], { relativeTo: this.route }); + // this.listView = false; + // } showListView(status: boolean){ // alert(2); @@ -147,6 +148,7 @@ export class EntityListComponent implements OnInit { } changeListView(){ + this.getEntityListMasters(); this.listView = true; } @@ -170,6 +172,25 @@ export class EntityListComponent implements OnInit { console.log(e); } + addNewEntity(): void { + const dialogRef = this.dialog.open(EntityAddComponent, { + disableClose: true, + data: { } + }); + + dialogRef.afterClosed().subscribe(result => { + if(result != null) { + this.getEntityListMasters(); + this.editEntity({'entity_id':result.record}); + } else { + + } + console.log('The dialog was closed'); + // alert(result); + }); + } + + } // {"dataStatus":true,"status":200,"records": diff --git a/ng6-seed/src/app/settings/entity/entity.module.ts b/ng6-seed/src/app/settings/entity/entity.module.ts index 1a6e67afe..2c753d9cd 100644 --- a/ng6-seed/src/app/settings/entity/entity.module.ts +++ b/ng6-seed/src/app/settings/entity/entity.module.ts @@ -13,7 +13,8 @@ import { MatToolbarModule,MatSelectModule, MatListModule, MatMenuModule, MatCheckboxModule,MatTabsModule, - MatExpansionModule + MatExpansionModule, + MatChipsModule } from '@angular/material'; import {MatSlideToggleModule} from '@angular/material/slide-toggle'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; @@ -31,6 +32,10 @@ import { EntityEditRegionComponent } from './entity-edit/entity-edit-region/enti import { EntityEditTatComponent } from './entity-edit/entity-edit-tat/entity-edit-tat.component'; import { EntityEditPriceComponent } from './entity-edit/entity-edit-price/entity-edit-price.component'; import { EntityEditBillingInfoComponent } from './entity-edit/entity-edit-billing-info/entity-edit-billing-info.component'; + +import { DialogAddEditBillingInfo } from './entity-edit/entity-edit-billing-info/entity-edit-billing-info.component'; +import { EntityEditVendorCityInfoComponent } from './entity-edit/entity-edit-vendor-city-info/entity-edit-vendor-city-info.component'; + /** * Custom angular notifier options */ @@ -89,6 +94,7 @@ const customNotifierOptions: NotifierOptions = { MatToolbarModule,MatSelectModule,MatListModule, MatMenuModule, MatCheckboxModule, MatTabsModule, + MatChipsModule, MatExpansionModule, MatSlideToggleModule, FormsModule, @@ -102,10 +108,14 @@ const customNotifierOptions: NotifierOptions = { EntityEditRegionComponent, EntityEditTatComponent, EntityEditPriceComponent, - EntityEditBillingInfoComponent + EntityEditBillingInfoComponent, + DialogAddEditBillingInfo, + EntityEditVendorCityInfoComponent ], entryComponents: [ // EntityEditComponent + DialogAddEditBillingInfo, + EntityAddComponent ], providers : [ EntityService diff --git a/ng6-seed/src/app/settings/service/entity/entity.service.ts b/ng6-seed/src/app/settings/service/entity/entity.service.ts index 9993bf8f3..eb5ca70f8 100644 --- a/ng6-seed/src/app/settings/service/entity/entity.service.ts +++ b/ng6-seed/src/app/settings/service/entity/entity.service.ts @@ -73,7 +73,7 @@ export class EntityService { updateEntityMasterDetails(Records: any): Observable { Records.fk_updatedby = this._aws.getlocale();//to get user id for who is created the Record Records.updatedon = currentdate;//to get Current date and Time for when the Record is created - return this._http.post(this.apiUrl + "saveExistEntity", { 'records': Records}) + return this._http.post(this.apiUrl + "saveNewEntity", { 'records': Records}) .pipe( catchError(this.handleError('role', [])) ) @@ -88,6 +88,84 @@ export class EntityService { ) } + + // =========================================== Entity New Details + + getEntityIdNameDetails(entity_id: any): Observable{ + // Add safe, URL encoded search parameter if there is a search term + const options = entity_id ? + { params: new HttpParams().set('eid', entity_id) } : {}; + + return this._http.get(this.apiUrl + "getEntityMasterInfo", options); + } + + updateEntityIdNameDetails(Records: any): Observable{ + + let records = Records.map(item=>{ + item.updatedby = this._aws.getlocale();//to get user id for who is created the Record + item.updatedon = currentdate;//to get Current date and Time for when the Record is created + return item; + }); + return this._http.post(this.apiUrl + "saveTemplateLenderDetails", {'records': records }); + } + + getEntityIdBillingInfoDetails(entity_id: any): Observable{ + // Add safe, URL encoded search parameter if there is a search term + const options = entity_id ? + { params: new HttpParams().set('eid', entity_id) } : {}; + + return this._http.get(this.apiUrl + "getEntityBillingInfo", options); + } + + updateEntityIdBillingInfoDetails(Records: any): Observable{ + + Records.updatedby = this._aws.getlocale();//to get user id for who is created the Record + Records.updatedon = currentdate;//to get Current date and Time for when the Record is created + + return this._http.post(this.apiUrl + "saveEntityBillingInfo", {'records': Records }); + } + + getEntityIdRegionInfoDetails(entity_id: any): Observable{ + // Add safe, URL encoded search parameter if there is a search term + const options = entity_id ? + { params: new HttpParams().set('entityid', entity_id) } : {}; + + return this._http.get(this.apiUrl + "getEntityRegionCityMap", options); + } + + updateEntityIdRegionInfoDetails(Records: any): Observable{ + let records = Records.map(item=>{ + item.fk_updatedby = this._aws.getlocale();//to get user id for who is created the Record + item.updatedon = currentdate;//to get Current date and Time for when the Record is created + item.createdon = item.createdon == null ? currentdate : item.createdon; + item.fk_createdby = item.fk_createdby == null ? this._aws.getlocale() : item.fk_createdby; + return item; + }); + return this._http.post(this.apiUrl + "saveEntityRegionMapping", {'records': records }); + } + + getCityHierarchyMaster() : Observable{ + return this._http.get(this.apiUrl + "getCityHierarchy"); + } + + getEntityIdCityInfoDetails(entity_id: any): Observable{ + // Add safe, URL encoded search parameter if there is a search term + const options = entity_id ? + { params: new HttpParams().set('entityid', entity_id) } : {}; + + return this._http.get(this.apiUrl + "getVendorCityMap", options); + } + + updateEntityIdCityInfoDetails(Records: any): Observable{ + + Records.fk_updatedby = this._aws.getlocale();//to get user id for who is created the Record + Records.updatedon = currentdate;//to get Current date and Time for when the Record is created + + return this._http.post(this.apiUrl + "saveVendorCityMapping", {'records': Records }); + } + + + /** * TO Handle The Error */