diff --git a/HRM.UI/ClientApp/src/app/_services/employee/employee.service.ts b/HRM.UI/ClientApp/src/app/_services/employee/employee.service.ts index aed9ed3..f66e584 100644 --- a/HRM.UI/ClientApp/src/app/_services/employee/employee.service.ts +++ b/HRM.UI/ClientApp/src/app/_services/employee/employee.service.ts @@ -504,7 +504,7 @@ export class EmployeeServices { return this.apiService.httpPost('/Employee/updateBanglaInformation', params); } updateBanglaContactInformation(params : any) { - return this.apiService.httpPost('/Employee/updateBanglaContactInformation', params); + return this.apiService.httpPost('/Employee/updateBanglaContactInformation', params); } getPFExceptionData() { return this.apiService.httpGet('/Employee/getPFExceptionData'); diff --git a/HRM.UI/ClientApp/src/app/core-hr/core-hr.module.ts b/HRM.UI/ClientApp/src/app/core-hr/core-hr.module.ts index 20b95ae..c1715b2 100644 --- a/HRM.UI/ClientApp/src/app/core-hr/core-hr.module.ts +++ b/HRM.UI/ClientApp/src/app/core-hr/core-hr.module.ts @@ -35,6 +35,7 @@ import { TextBoxModule } from "@progress/kendo-angular-inputs"; import { LabelModule } from "@progress/kendo-angular-label"; import { FloatingLabelModule } from "@progress/kendo-angular-label"; import { IconsModule } from "@progress/kendo-angular-icons"; +import { UploadModule } from '@progress/kendo-angular-upload'; import { ReactiveFormsModule, FormsModule } from '@angular/forms'; import { TabViewModule } from 'primeng/tabview'; @@ -129,7 +130,8 @@ import { HallOfFameUploaderComponent } from './hall-of-fame-uploader/hall-of-fam IconsModule, LabelModule, PanelModule, - CardManagemnetModule + CardManagemnetModule, + UploadModule ], declarations: [ NationalityComponent, diff --git a/HRM.UI/ClientApp/src/app/core-hr/employee-profile/contact/contact.component.ts b/HRM.UI/ClientApp/src/app/core-hr/employee-profile/contact/contact.component.ts index c21d073..739d936 100644 --- a/HRM.UI/ClientApp/src/app/core-hr/employee-profile/contact/contact.component.ts +++ b/HRM.UI/ClientApp/src/app/core-hr/employee-profile/contact/contact.component.ts @@ -45,8 +45,9 @@ export class ContactComponent implements OnInit { this.basicService.getAllDistricts().subscribe((resp) => { this.districts = resp; }, - () => { - + (err: any) => { + this.loadingPanel.ShowLoadingPanel = false; + this.notificationService.showError(err.error); }, () => { @@ -58,8 +59,9 @@ export class ContactComponent implements OnInit { this.basicService.getAllThanas(value).subscribe((resp) => { this.permanentThanas = resp; }, - () => { - + (err: any) => { + this.loadingPanel.ShowLoadingPanel = false; + this.notificationService.showError(err.error); }, () => { @@ -71,8 +73,9 @@ export class ContactComponent implements OnInit { this.basicService.getAllThanas(value).subscribe((resp) => { this.presentThanas = resp; }, - () => { - + (err: any) => { + this.loadingPanel.ShowLoadingPanel = false; + this.notificationService.showError(err.error); }, () => { @@ -135,7 +138,8 @@ export class ContactComponent implements OnInit { } }, (err: any) => { - + this.loadingPanel.ShowLoadingPanel = false; + this.notificationService.showError(err.error); }, () => { if (this.employeeService.hrEmployee.id != undefined && this.employeeService.hrEmployee.id != 0) { @@ -147,7 +151,9 @@ export class ContactComponent implements OnInit { this.basicService.getAllRelations().subscribe((resp) => { this.relations = resp; }, - () => { + (err) => { + this.loadingPanel.ShowLoadingPanel = false; + this.notificationService.showError(err.error); }, () => { @@ -186,8 +192,9 @@ export class ContactComponent implements OnInit { (resp) => { this.contact.id = resp; }, - () => { + (err) => { this.loadingPanel.ShowLoadingPanel = false; + this.notificationService.showError(err.error); }, () => { this.loadingPanel.ShowLoadingPanel = false; @@ -222,8 +229,9 @@ export class ContactComponent implements OnInit { this.presentThanas = resp; this.contact.presentThanaID = this.contact.permanentThanaID; }, - () => { - + (err) => { + this.loadingPanel.ShowLoadingPanel = false; + this.notificationService.showError(err.error); }, () => { diff --git a/HRM.UI/ClientApp/src/app/core-hr/employee-profile/employee-profile.component.ts b/HRM.UI/ClientApp/src/app/core-hr/employee-profile/employee-profile.component.ts index 51843b8..664c5da 100644 --- a/HRM.UI/ClientApp/src/app/core-hr/employee-profile/employee-profile.component.ts +++ b/HRM.UI/ClientApp/src/app/core-hr/employee-profile/employee-profile.component.ts @@ -40,8 +40,9 @@ export class EmployeeProfileComponent implements OnInit { activeIndex: number = 0; previousIndex: number = 0; // 👈 track the previous tab index manually @ViewChild('general') generalComponent!: GeneralComponent; - @ViewChild('Contact') contactComponent!: ContactComponent; + @ViewChild('contact') contactComponent!: ContactComponent; newEmpSaved: boolean = false; + newEmpContactSaved: boolean = false; constructor(private fb: FormBuilder, @@ -351,7 +352,7 @@ export class EmployeeProfileComponent implements OnInit { setTimeout(() => { - if (this.generalComponent.personalInfo.valid === false && this.generalComponent.hrEmployee.employeeNo === '') { + if (this.generalComponent != undefined && this.generalComponent.personalInfo.valid === false && this.generalComponent.hrEmployee.employeeNo === '') { this.notificationService.showError('Required Fields Can\'t Be Empty'); this.activeIndex = currentIndex; this.previousIndex = currentIndex; @@ -362,30 +363,57 @@ export class EmployeeProfileComponent implements OnInit { return; }); } - if (currentTab.header.toLowerCase() == 'contacts') { - debugger - // this.contactComponent.ngOnInit(); + if (currentTab.header.toLowerCase() == 'contacts' && !this.newEmpContactSaved) { + setTimeout(() => { + + if (!this.contactComponent.contactForm.valid) { + this.notificationService.showWarning('Must Entry field can\'t be Empty'); + this.activeIndex = currentIndex; + this.previousIndex = currentIndex; + return; + } + this.contactComponent.SaveContact(); + this.newEmpContactSaved = true; + return; + }); } } - - - - console.log('Previous Tab:', currentIndex, currentTab.header); - console.log('Next Tab:', nextIndex, nextTab.header); - - // // Example validation logic on current tab before switching - // if (currentIndex === 0 && this.form1.invalid) { - // this.form1.markAllAsTouched(); - // setTimeout(() => (this.activeIndex = currentIndex)); // cancel switch - // return; - // } - - // if (currentIndex === 1 && this.form2.invalid) { - // this.form2.markAllAsTouched(); - // setTimeout(() => (this.activeIndex = currentIndex)); // cancel switch - // return; - // } - + if (currentTab.header.toLowerCase() == 'general') { + if (this.generalComponent != undefined && this.contactComponent != undefined) { + if (this.generalComponent.contact.id == 0) { + this.contactComponent.contact.id = this.generalComponent.contact.id; + } + if (this.generalComponent.contact.presentPOInBangla != null && this.generalComponent.contact.presentPOInBangla != "") { + this.contactComponent.contact.presentPOInBangla = this.generalComponent.contact.presentPOInBangla; + } + if (this.generalComponent.contact.presentAddressInBangla != null && this.generalComponent.contact.presentAddressInBangla != "") { + this.contactComponent.contact.presentAddressInBangla = this.generalComponent.contact.presentAddressInBangla; + } + if (this.generalComponent.contact.parmanentPOInBangla != null && this.generalComponent.contact.parmanentPOInBangla != "") { + this.contactComponent.contact.parmanentPOInBangla = this.generalComponent.contact.parmanentPOInBangla; + } + if (this.generalComponent.contact.permanentAddressInBangla != null && this.generalComponent.contact.permanentAddressInBangla != "") { + this.contactComponent.contact.permanentAddressInBangla = this.generalComponent.contact.permanentAddressInBangla; + } + } + } + if (nextTab.header.toLowerCase() == 'attachments') { + debugger; + this.employeeService.getEmployeeAttachments(this.selectedEmployee.employeeID) + .subscribe( + (resp) => { + this.attachments = resp; + }, + (x) => { + console.log(x); + this.loadingPanel.ShowLoadingPanel = false; + }, + () => { + this.loadingPanel.ShowLoadingPanel = false; + this.hrEmployeeProfile.attachments = this.attachments; + } + ); + } // ✅ Save current as previous after successful switch this.previousIndex = nextIndex; } diff --git a/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.html b/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.html index b99f631..75a5340 100644 --- a/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.html +++ b/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.html @@ -260,8 +260,11 @@ - + (click)="popUpAttachment('NID')" [disabled]="!active"> + +
@@ -363,7 +366,7 @@
@@ -597,7 +600,7 @@
diff --git a/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.ts b/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.ts index 3c12a4a..7576f34 100644 --- a/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.ts +++ b/HRM.UI/ClientApp/src/app/core-hr/employee-profile/general/general.component.ts @@ -33,6 +33,8 @@ import { Nationality } from '../../nationality/nationality'; import { EmpContact } from 'src/app/_models/HREmployee/empContact'; import { Thana } from '../../thana/thana'; import { CardManagemnetModule } from 'src/app/attendance/access-card-management/card-management.module'; +import { Observable, EMPTY } from 'rxjs'; +import { tap, finalize, catchError } from 'rxjs/operators'; @Component({ selector: 'app-general', @@ -557,6 +559,75 @@ export class GeneralComponent implements OnInit { this.NIDFiles = undefined; } } + private getSavePersonalInfoObservable(): Observable | null { + debugger; + if (this.personalInfo.valid === false && this.hrEmployee.employeeNo === '') { + this.notificationService.showError('Required Fields Can\'t Be Empty'); + return null; + } + + this.loadingPanel.ShowLoadingPanel = true; + this.hrEmployee.name = this.hrEmployee.firstName; + if (this.hrEmployee.middleName !== null) { + this.hrEmployee.name += ' ' + this.hrEmployee.middleName; + } + if (this.hrEmployee.lastName !== null) { + this.hrEmployee.name += ' ' + this.hrEmployee.lastName; + } + + return this.employeeService.saveHrPersonalInfo(this.hrEmployee).pipe( + tap((resp: HrEmployee) => { + debugger; + if (resp != undefined) { + this.hrEmployee.id = resp.id; + if (!this.active) { + this.hrEmployee.employeeNo = resp.employeeNo; + this.employeeService.hrEmployee = resp; + } + + if (this.selectedTinFiles?.length > 0) { + this.saveFile(this.hrEmployee.id, this.selectedTinFiles, enumEmpFileUploadType.TIN); + } + if (this.selectedNidFiles?.length > 0) { + this.saveFile(this.hrEmployee.id, this.selectedNidFiles, enumEmpFileUploadType.nationalID); + } + if (this.selectedDlFiles?.length > 0) { + this.saveFile(this.hrEmployee.id, this.selectedDlFiles, enumEmpFileUploadType.DrivingLicense); + } + } + }), + finalize(() => { + this.loadingPanel.ShowLoadingPanel = false; + }), + catchError((err) => { + debugger; + console.error(err); + this.notificationService.showError(err.error); + return EMPTY; // No emission on error + }) + ); + } + saveBanglaInfo() { + if (!this.active) { + const personalInfo$ = this.getSavePersonalInfoObservable(); + if (personalInfo$) { + personalInfo$.subscribe({ + next: () => { + debugger; + this.isDisplay = false; + this.notificationService.showSuccess('Data saved successfully'); + this.SaveBanglaContactInformation(); + } + }); + } + else { + this.isDisplay = false; + } + // If null, validation failed — nothing is executed + } else { + this.SaveBanglaContactInformation(); + } + } saveBanglaPersonalInformation() { const data = { employeeNo: this.employeeService.hrEmployee.employeeNo, @@ -591,6 +662,14 @@ export class GeneralComponent implements OnInit { this.loadingPanel.ShowLoadingPanel = true; this.employeeService.updateBanglaContactInformation(data).subscribe( (resp: any) => { + // debugger + // if(this.contact.id == 0) + // this.employeeService.hrEmployee.contacts[0].id = resp; + + // this.employeeService.hrEmployee.contacts[0].presentPOInBangla = this.contact.presentPOInBangla; + // this.employeeService.hrEmployee.contacts[0].presentAddressInBangla = this.contact.presentAddressInBangla, + // this.employeeService.hrEmployee.contacts[0].parmanentPOInBangla = this.contact.parmanentPOInBangla; + // this.employeeService.hrEmployee.contacts[0].permanentAddressInBangla = this.contact.permanentAddressInBangla; }, (err) => { this.loadingPanel.ShowLoadingPanel = false; @@ -956,4 +1035,6 @@ export class GeneralComponent implements OnInit { this.passnoPopUp = false; this.signaturePopUp = false; } + // uploadSaveUrl = "saveUrl"; // should represent an actual API endpoint + // uploadRemoveUrl = "removeUrl"; // should represent an actual API endpoint } diff --git a/HRM.UI/Controllers/Employee/EmployeeController.cs b/HRM.UI/Controllers/Employee/EmployeeController.cs index b18f097..1e969b1 100644 --- a/HRM.UI/Controllers/Employee/EmployeeController.cs +++ b/HRM.UI/Controllers/Employee/EmployeeController.cs @@ -2165,6 +2165,7 @@ namespace HRM.UI.Controllers ec.PresentAddressInBangla = presentAddressInBangla; ec.PermanentAddressInBangla = presentAddressInBangla; _hrEmployeeService.SaveContact(ec); + return Ok(ec.ID); } } catch (Exception ex) diff --git a/HRM.UI/Documents/EMPPHOTO/Signature-88216.jpg b/HRM.UI/Documents/EMPPHOTO/Signature-88216.jpg new file mode 100644 index 0000000..90347f6 Binary files /dev/null and b/HRM.UI/Documents/EMPPHOTO/Signature-88216.jpg differ