diff --git a/ng6-seed/src/app/settings/company-details/company-details.module.spec.ts b/ng6-seed/src/app/settings/company-details/company-details.module.spec.ts deleted file mode 100644 index db014c808..000000000 --- a/ng6-seed/src/app/settings/company-details/company-details.module.spec.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { CompanyDetailsModule } from './company-details.module'; - -describe('CompanyDetailsModule', () => { - let companyDetailsModule: CompanyDetailsModule; - - beforeEach(() => { - companyDetailsModule = new CompanyDetailsModule(); - }); - - it('should create an instance', () => { - expect(companyDetailsModule).toBeTruthy(); - }); -}); diff --git a/ng6-seed/src/app/settings/company-details/company-details.module.ts b/ng6-seed/src/app/settings/company-details/company-details.module.ts deleted file mode 100644 index 1c7bfd8aa..000000000 --- a/ng6-seed/src/app/settings/company-details/company-details.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; - -@NgModule({ - imports: [ - CommonModule - ], - declarations: [] -}) -export class CompanyDetailsModule { } diff --git a/ng6-seed/src/app/settings/company-details/company-details.routing.ts b/ng6-seed/src/app/settings/company-details/company-details.routing.ts deleted file mode 100755 index acac68aca..000000000 --- a/ng6-seed/src/app/settings/company-details/company-details.routing.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Routes } from '@angular/router'; -//import { MastersComponent } from './masters.component'; - - -export const CompanyDetailsRoutes: Routes = [ -{ - - //path: '', - //component: PdTeamListComponent - //component: IndustryMasterListComponent - -}]; diff --git a/ng6-seed/src/app/settings/masters/component/branch/branch-list/branch-list.component.html b/ng6-seed/src/app/settings/masters/component/branch/branch-list/branch-list.component.html index d7fb9940b..ac51af616 100644 --- a/ng6-seed/src/app/settings/masters/component/branch/branch-list/branch-list.component.html +++ b/ng6-seed/src/app/settings/masters/component/branch/branch-list/branch-list.component.html @@ -54,7 +54,7 @@ onclick="return confirm('Are you sure?')"> - +

Company                                                 

+ +
+ +
+ + +
+ + + + + +
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + + + {{ cd.name }} + + + + +
+ +
+ + + {{ sd.name }} + + + +
+ +
+ + + pincode should be in 6 digit format + + + + +
+ +
+ +
+ + + + + +
+ +
+
+ \ No newline at end of file diff --git a/ng6-seed/src/app/settings/masters/component/company/company.component.scss b/ng6-seed/src/app/settings/masters/component/company/company.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/ng6-seed/src/app/settings/masters/component/company/company.component.spec.ts b/ng6-seed/src/app/settings/masters/component/company/company.component.spec.ts new file mode 100644 index 000000000..d56536e7e --- /dev/null +++ b/ng6-seed/src/app/settings/masters/component/company/company.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CompanyComponent } from './company.component'; + +describe('CompanyComponent', () => { + let component: CompanyComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CompanyComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CompanyComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/settings/masters/component/company/company.component.ts b/ng6-seed/src/app/settings/masters/component/company/company.component.ts new file mode 100644 index 000000000..17b2f760f --- /dev/null +++ b/ng6-seed/src/app/settings/masters/component/company/company.component.ts @@ -0,0 +1,180 @@ + +import { Component, + OnInit, + Inject } from '@angular/core'; +import { FormBuilder, + FormGroup, + Validators, + FormControl } from '@angular/forms'; + +/** Service */ +import { MastersService } from '../../../service/masters/masters.service'; + + +@Component({ + selector: 'app-company', + templateUrl: './company.component.html', + styleUrls: ['./company.component.scss'] +}) + +export class CompanyComponent implements OnInit { + + public _companyForm: FormGroup; + public companyData: any = []; + + stateDatas: any[]; + citydatas: any[]; + errorMessage:string; + + + constructor(private _formBuilder: FormBuilder, + private _mastersService: MastersService) { } + + FetchFormValue() { + this._mastersService.getAllCompany().subscribe( + dataresult => { + if(dataresult.dataStatus == true){ + + this.companyData = dataresult.records; + + this._companyForm.controls['company_id'].setValue(this.companyData[0].company_id); + this._companyForm.controls['name'].setValue(this.companyData[0].name); + this._companyForm.controls['addressline1'].setValue(this.companyData[0].addressline1); + this._companyForm.controls['addressline2'].setValue(this.companyData[0].addressline2); + this._companyForm.controls['addressline3'].setValue(this.companyData[0].addressline3); + this._companyForm.controls['city'].setValue(this.companyData[0].city); + this._companyForm.controls['state'].setValue(this.companyData[0].state); + this._companyForm.controls['pincode'].setValue(this.companyData[0].pincode); + } + } + ) +} + ngOnInit() { + + this.CompanyFormData(); + this.FetchFormValue(); + // this._mastersService.getAllCompany().subscribe( + // dataresult => { + // if(dataresult.dataStatus == true){ + + // this.companyData = dataresult.records; + + // this._companyForm.controls['company_id'].setValue(this.companyData[0].company_id); + // this._companyForm.controls['name'].setValue(this.companyData[0].name); + // this._companyForm.controls['addressline1'].setValue(this.companyData[0].addressline1); + // this._companyForm.controls['addressline2'].setValue(this.companyData[0].addressline2); + // this._companyForm.controls['addressline3'].setValue(this.companyData[0].addressline3); + // this._companyForm.controls['city'].setValue(this.companyData[0].city); + // this._companyForm.controls['state'].setValue(this.companyData[0].state); + // this._companyForm.controls['pincode'].setValue(this.companyData[0].pincode); + // } + // } + // ) + + + this._mastersService.getAllMasterData('STATE') + .subscribe( + data => { + if (data.dataStatus == true){ + this.stateDatas = data.records; + this.stateDatas = this.stateDatas.filter(dataresult=>dataresult.isactive == 1 ); + } + + }, error => this.errorMessage = error); + + this._mastersService.getAllMasterData('CITY') + .subscribe( + data => { + if (data.dataStatus == true){ + this.citydatas = data.records; + this.citydatas = this.citydatas.filter(dataresult=>dataresult.isactive == 1 ); + //this._companyForm.controls['state'].setValue(this.companyData[0].state); + } + }, error => this.errorMessage = error); + } + + + getRelevantState(event){ + // console.log(event); + // console.log('cityid',event.value); + // console.log('statedata',this.stateDatas); + //let cityid = event.value; + let alldata = this.citydatas.filter(data => data.city_id == event.value); + // console.log('to getrelated id datas',alldata); + // console.log('get correct', alldata[0].name); + this._companyForm.controls['state'].setValue(alldata[0].fk_state_id); + //event.source.disabled = true; + } + + /** For CompanyFormData */ + CompanyFormData() { + + this._companyForm = this._formBuilder.group({ + + company_id: [null], + name: [null, Validators.compose([Validators.required])], + addressline1: [null, Validators.compose([Validators.required])], + addressline2: [null], + addressline3: [null], + city: [null, Validators.compose([Validators.required])], + state: [null,{disabled: true}], + pincode: [null, Validators.compose([Validators.required, Validators.minLength(5), Validators.maxLength(6)])], + + }); +} + + + /** To Save/Edited Popup Data */ + onSubmit() { + + var CompanyFormValue = this._companyForm.value; + + if(isNaN(this._companyForm['company_id'])) + { + + Object.keys(CompanyFormValue).forEach((key) => ( CompanyFormValue[key] == null) && delete CompanyFormValue[key]); + + //After Saving the Company data then popup close + this._mastersService.addCompanyDetails(CompanyFormValue).subscribe( + + dataresult=>{ + if (dataresult.dataStatus == true){ + + alert("Data Saved Successfully"); + } + else{ + alert("SomeThing Wents Wrong Try Again !"); + } + + }); + + } else { + + this._mastersService.editMasterDetails(CompanyFormValue,'COMPANY').subscribe( + dataresult=>{ + if (dataresult.dataStatus == true){ + + alert("Data Edited Successfully"); + } + else{ + alert("SomeThing Wents Wrong Try Again !"); + } + + } + ); + } + } + + + +/** To Reset Popup Data For Edit*/ +onResetForEdit(){ + //this.CompanyFormData(); + this.FetchFormValue(); +} + +isEmptyObject(obj) { + return (obj && (Object.keys(obj).length === 0)); +} + +} diff --git a/ng6-seed/src/app/settings/masters/masters.component.html b/ng6-seed/src/app/settings/masters/masters.component.html index d8d42e07b..c1825639c 100644 --- a/ng6-seed/src/app/settings/masters/masters.component.html +++ b/ng6-seed/src/app/settings/masters/masters.component.html @@ -7,7 +7,10 @@
- + + {{master.name}} @@ -70,9 +73,10 @@
- +
+ + +
diff --git a/ng6-seed/src/app/settings/masters/masters.component.ts b/ng6-seed/src/app/settings/masters/masters.component.ts index 34529d22d..3c840fa23 100644 --- a/ng6-seed/src/app/settings/masters/masters.component.ts +++ b/ng6-seed/src/app/settings/masters/masters.component.ts @@ -3,7 +3,7 @@ //import { startWith } from 'rxjs/operators'; - import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; + import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild, Input } from '@angular/core'; import { FormControl, FormGroup, FormBuilder } from '@angular/forms'; import { ReplaySubject } from 'rxjs'; import { MatSelect } from '@angular/material'; @@ -118,7 +118,7 @@ export class MastersComponent implements OnInit { {id: 'master-16',name: 'Customer Segment'}, {id: 'master-17',name: 'Designation'}, {id: 'master-18',name: 'Lender Hierarchy'}, - // {id: 'master-19',name: 'Company Details'}, + {id: 'master-19',name: 'Company Details'}, {id: 'master-20',name: 'Question Category'}, {id: 'master-21',name: 'PD Type'}, {id: 'master-22',name: 'Approach to PD location'}, @@ -126,15 +126,13 @@ export class MastersComponent implements OnInit { {id: 'master-24',name: 'PD Notification'}, // {id: 'master-25',name: 'PD Office Lender'}, // {id: 'master-25',name: 'PD Team'}, - - ]; /** list of masters filtered by search keyword */ public filteredMasters: ReplaySubject = new ReplaySubject(1); - @ViewChild('singleSelect') singleSelect: MatSelect; + /** Subject that emits when the component has been destroyed. */ private _onDestroy = new Subject(); @@ -151,10 +149,10 @@ export class MastersComponent implements OnInit { // listen for search field value changes this.masterFilterCtrl.valueChanges - .pipe(takeUntil(this._onDestroy)) - .subscribe(() => { - this.filterMasters(); - }); + .pipe(takeUntil(this._onDestroy)) + .subscribe(() => { + this.filterMasters(); + }); } diff --git a/ng6-seed/src/app/settings/masters/masters.module.ts b/ng6-seed/src/app/settings/masters/masters.module.ts index 3690e9add..5a37c89bf 100644 --- a/ng6-seed/src/app/settings/masters/masters.module.ts +++ b/ng6-seed/src/app/settings/masters/masters.module.ts @@ -82,6 +82,7 @@ import { CityDialogComponent } from './component/city/city-dialog/city-dialog.co import { RegionsDialogComponent } from './component/regions/regions-dialog/regions-dialog.component'; import { QuestionCategoryDialogComponent } from './component/question-category/question-category-dialog/question-category-dialog.component'; import { PdNotificationListComponent } from './component/pd-notification/pd-notification-list.component'; +import { CompanyComponent } from './component/company/company.component'; //import { PdTeamListComponent } from './component/pd-team/pd-team-list/pd-team-list.component'; @@ -206,6 +207,7 @@ const customNotifierOptions: NotifierOptions = { CustomerSegmentDialogComponent, StatesDialogComponent, CompanyDialogComponent, + CompanyComponent, CityDialogComponent, RegionsDialogComponent, QuestionCategoryDialogComponent, diff --git a/ng6-seed/src/app/settings/pd-team/pd-team-edit/pd-team-edit.component.html b/ng6-seed/src/app/settings/pd-team/pd-team-edit/pd-team-edit.component.html index 42f4f724f..f3fc99660 100644 --- a/ng6-seed/src/app/settings/pd-team/pd-team-edit/pd-team-edit.component.html +++ b/ng6-seed/src/app/settings/pd-team/pd-team-edit/pd-team-edit.component.html @@ -28,7 +28,7 @@
- {{ cd.name }} + {{ cd.name }} You must Select Cities. @@ -78,7 +78,7 @@
- +
diff --git a/ng6-seed/src/app/settings/pd-team/pd-team-edit/pd-team-edit.component.ts b/ng6-seed/src/app/settings/pd-team/pd-team-edit/pd-team-edit.component.ts index a0cc5afa9..2463d5b52 100644 --- a/ng6-seed/src/app/settings/pd-team/pd-team-edit/pd-team-edit.component.ts +++ b/ng6-seed/src/app/settings/pd-team/pd-team-edit/pd-team-edit.component.ts @@ -162,9 +162,9 @@ export class PdTeamEditComponent implements OnInit { } /** To Reset Popup Data For Add*/ - onResetForEdit(){ - this.PdTeamFormDatas(); - } + // onResetForEdit(){ + // this.PdTeamFormDatas(); + // } /**on change function for customer segment to dispaly the as List in html page */ onChangeCustomerSegmentDatas($event){ @@ -182,11 +182,12 @@ export class PdTeamEditComponent implements OnInit { /**on change function for City to display the as List in html page */ onChangeCityDatas($event){ + var mycheck = 0 ; - //let cityName = $event.source.value; + let cityName = this.citydatas.filter(city=>city.city_id == $event.source.value)[0]; - if($event.source._selected === true ){ + if($event.source._selected == true ){ for(let Duplication_City of this.pdTeamCityArray){ @@ -199,7 +200,7 @@ export class PdTeamEditComponent implements OnInit { if(data.name == cityName.name){ alert('"'+data.name+'" Already Existing with "'+ teamname +'"'); $event.source._selected = false; - mycheck++; + mycheck=1; } } @@ -216,6 +217,7 @@ export class PdTeamEditComponent implements OnInit { this.selectedCityDatas.splice(index,1); } } + /**on change function for Product to display the data as List in html page */ onChangeProductDatas($event){ @@ -241,7 +243,7 @@ export class PdTeamEditComponent implements OnInit { this._pdTeamService.editPdTeamDetail(pdTeamFormValues).subscribe( - dataresult=>{ + dataresult=>{ if (dataresult.dataStatus == true){ alert("Data Edited Successfully"); this.notifier.notify('success', 'Record Edited Successfully.!'); diff --git a/ng6-seed/src/app/settings/pd-team/pd-team-list/pd-team-list.component.html b/ng6-seed/src/app/settings/pd-team/pd-team-list/pd-team-list.component.html index 848631ed1..7e36688bb 100644 --- a/ng6-seed/src/app/settings/pd-team/pd-team-list/pd-team-list.component.html +++ b/ng6-seed/src/app/settings/pd-team/pd-team-list/pd-team-list.component.html @@ -19,7 +19,7 @@
- +
@@ -76,7 +76,7 @@ - + diff --git a/ng6-seed/src/app/settings/pd-team/pd-team-list/pd-team-list.component.ts b/ng6-seed/src/app/settings/pd-team/pd-team-list/pd-team-list.component.ts index 390529b82..080c4c401 100644 --- a/ng6-seed/src/app/settings/pd-team/pd-team-list/pd-team-list.component.ts +++ b/ng6-seed/src/app/settings/pd-team/pd-team-list/pd-team-list.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, ViewChild } from '@angular/core'; -import { Router } from '@angular/router'; + import { MatSort, MatPaginator, MatTableDataSource } from '@angular/material'; @@ -29,6 +29,7 @@ export class PdTeamListComponent implements OnInit { loader: boolean = false; PdTeamList: any = []; color = 'primary'; + pageSize = 10; userData = null; noRecordFound: boolean = false; @@ -44,7 +45,7 @@ export class PdTeamListComponent implements OnInit { @ViewChild(MatSort) sort: MatSort; constructor(notifier: NotifierService, - private router: Router, + private _MasterService: MastersService, private _PdTeamService: PdTeamService) { this.getPdTeam(); @@ -53,11 +54,6 @@ export class PdTeamListComponent implements OnInit { ngOnInit() { this.getPdTeam(); } - /** To add data */ - addPdTeam() { - this.router.navigate(['/setting/pdteam/addpdteam']); - } - /** To edit data */ editPdTeam(detail){ @@ -99,6 +95,25 @@ export class PdTeamListComponent implements OnInit { } }) } + + /** For Changing Active States., which means both Changing Active And Inactive alternatively */ + isactivePdTeam(id: number,isactive : number) { + + let ActiveDatas = isactive == 0 + ? { 'pdteam_id':id,'isactive': '1'} + : { 'pdteam_id':id,'isactive': '0'} + + this._MasterService.editMasterDetails(ActiveDatas,'PDTEAM') + .subscribe(dataresult=>{ + if (dataresult.dataStatus == true){ + //alert("my check"); + this.getPdTeam(); + } + else{ + alert("SomeThing Wents Wrong Try Again !"); + } + }); +} /** For Display Tables Pagination And Sorting */ ngAfterViewInit() { diff --git a/ng6-seed/src/app/settings/service/masters/masters.service.ts b/ng6-seed/src/app/settings/service/masters/masters.service.ts index 3015d8376..16a5ce73c 100644 --- a/ng6-seed/src/app/settings/service/masters/masters.service.ts +++ b/ng6-seed/src/app/settings/service/masters/masters.service.ts @@ -286,7 +286,7 @@ editPDAllocationType(Records: any,MasterName:string): Observable { // formData.append('logo',Records.logo); // formData.append('records',JSON.stringify(Records)); - return this._http.post(this.apiUrl+"saveCompany", ArrayData) + return this._http.post(this.apiUrl+"saveMaster", ArrayData) .pipe( catchError(this.handleError('role', [])) ) diff --git a/ng6-seed/src/app/settings/service/masters/pd-team.service.ts b/ng6-seed/src/app/settings/service/masters/pd-team.service.ts index 1b339e139..0a90bc3e8 100644 --- a/ng6-seed/src/app/settings/service/masters/pd-team.service.ts +++ b/ng6-seed/src/app/settings/service/masters/pd-team.service.ts @@ -64,7 +64,7 @@ return this._http.post(this.apiUrl+"savePDTeam", ArrayData) Records.updatedon = currentdate;//to get Current date and Time for when the Record is updated var ArrayData = { "records": Records } - + console.log(ArrayData); return this._http.post(this.apiUrl+'savePDTeam',ArrayData) .pipe( catchError(this.handleError('role', []))