HRM-10/HRM.UI/ClientApp/src/app/reports/discontinue-employee-details/discontinue-employee-details.component.ts

56 lines
2.2 KiB
TypeScript
Raw Normal View History

2026-11-09 14:41:04 +06:00
import { Component, ChangeDetectionStrategy, ViewChild } from '@angular/core';
2026-11-09 11:59:10 +06:00
import { DatePipe } from '@angular/common';
import { ApiService } from 'src/app/app.api.service';
import { HRMNotificationService } from 'src/app/app.notification.service';
2026-11-09 14:41:04 +06:00
import { VirtualGridComponent } from 'src/app/custom-components/virtual-grid/virtual-grid.component';
import { VirtualGridLoadedEvent } from 'src/app/_models/common/virtual-grid';
2026-11-09 11:59:10 +06:00
/**
2026-11-09 14:41:04 +06:00
* Discontinue Employee Details: employees discontinued inside a date range, with the same columns as
* Employee Details (/reports/report-viewer/empDetailInfo) plus the Discontinue Date.
*
* The grid is the common <app-virtual-grid> (server grid "discontinue-employee",
* HRM.DA/Service/VirtualGrid/Definitions/DiscontinueEmployeeVirtualGrid.cs); this screen only owns its filters.
2026-11-09 11:59:10 +06:00
*/
@Component({
selector: 'app-discontinue-employee-details',
templateUrl: './discontinue-employee-details.component.html',
styleUrls: ['./discontinue-employee-details.component.scss'],
changeDetection: ChangeDetectionStrategy.Eager,
standalone: false,
})
2026-11-09 14:41:04 +06:00
export class DiscontinueEmployeeDetailsComponent {
@ViewChild('grid') grid: VirtualGridComponent;
2026-11-09 11:59:10 +06:00
fromDate: Date = new Date(new Date().getFullYear(), new Date().getMonth(), 1);
toDate: Date = new Date();
dateFormat = 'dd-MMM-yyyy';
constructor(public apiService: ApiService,
public notificationService: HRMNotificationService,
private datePipe: DatePipe) {
this.apiService.selectedMenuName = 'Discontinue Employee Details';
}
preview(): void {
if (!this.fromDate || !this.toDate) {
this.notificationService.showWarning('Please select From Date and To Date.', 'Warning');
return;
}
if (this.fromDate > this.toDate) {
this.notificationService.showWarning('From Date cannot be after To Date.', 'Warning');
return;
}
2026-11-09 14:41:04 +06:00
this.grid.load({
fromDate: this.datePipe.transform(this.fromDate, 'yyyy-MM-dd'),
toDate: this.datePipe.transform(this.toDate, 'yyyy-MM-dd'),
});
2026-11-09 11:59:10 +06:00
}
2026-11-09 14:41:04 +06:00
onLoaded(event: VirtualGridLoadedEvent): void {
if (event.firstLoad && event.total === 0) {
this.notificationService.showWarning('No employee was discontinued in the selected date range.', 'Warning');
2026-11-09 11:59:10 +06:00
}
}
}