141 lines
5.0 KiB
TypeScript
141 lines
5.0 KiB
TypeScript
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
|
import { FormGroup, FormControl } from '@angular/forms';
|
|
import { Router } from '@angular/router';
|
|
import { SelectItem } from 'primeng/api';
|
|
import { ApiService } from '../../app.api.service';
|
|
import { HRMNotificationService } from '../../app.notification.service';
|
|
import { DataTransferService } from '../../data.transfer.service';
|
|
import { loadingPanelService } from '../../hrm-loding panel/loding.panel.service';
|
|
import { EmployeeWorkPlanSetup } from '../../_models/Attendance/employeeWorkPlanSetup';
|
|
import { SearchEmployee } from '../../_models/Employee/searchEmployee';
|
|
import { AttendanceServices } from '../../_services/attendance/attendance.service';
|
|
import { BasicService } from '../../_services/Basic/basic.service';
|
|
|
|
@Component({
|
|
selector: 'app-attendance-process',
|
|
templateUrl: './attendance-process.component.html'
|
|
})
|
|
|
|
export class AttendanceProcessComponent {
|
|
|
|
fromDate: Date;
|
|
toDate: Date;
|
|
selectedEmployees: SearchEmployee[] = [];
|
|
notYetAssingedList: EmployeeWorkPlanSetup[];
|
|
employees: any[] = [];
|
|
lastProcessDate: Date;
|
|
processStatus: string = "";
|
|
withEmployee: boolean = false;
|
|
constructor(public attnService: AttendanceServices, public datatransferservice: DataTransferService,
|
|
public loadingPanel: loadingPanelService,
|
|
public notificationService: HRMNotificationService,
|
|
public basicService: BasicService,
|
|
public apiService: ApiService,
|
|
public router: Router) {
|
|
this.apiService.selectedMenuName = "Attendance Process";
|
|
this.loadingPanel.ShowLoadingPanel = false;
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.notYetAssingedList = []
|
|
this.fromDate = new Date();
|
|
this.toDate = new Date();
|
|
this.attnService.getNotYetAssiged().subscribe(
|
|
(x) => {
|
|
this.employees = x;
|
|
},
|
|
(x) => {
|
|
},
|
|
() => {
|
|
});
|
|
this.attnService.getLastAttnProcessDate().subscribe(
|
|
(resp) => {
|
|
if (resp != null) {
|
|
this.lastProcessDate = new Date(resp);
|
|
}
|
|
|
|
},
|
|
(x) => {
|
|
},
|
|
() => {
|
|
});
|
|
|
|
}
|
|
public GetSelectedEmployee(childData) {
|
|
this.selectedEmployees = childData;
|
|
}
|
|
|
|
public onSave(e): void {
|
|
|
|
//if (this.selectedEmployees != undefined && this.selectedEmployees.length > 0) {
|
|
// if (this.notYetAssingedList != undefined && this.notYetAssingedList.length > 0) {
|
|
|
|
// this.selectedEmployees.forEach(x => {
|
|
// if (this.notYetAssingedList.findIndex(n => n.employeeID == x.employeeID) == -1) {
|
|
// this.notificationService.showWarning(x.name + " " + x.employeeNo + " doesn't have monthly work-plan");
|
|
// return;
|
|
// }
|
|
|
|
// });
|
|
// }
|
|
//}
|
|
//else if (this.notYetAssingedList.length >0) {
|
|
// if (this.notYetAssingedList != undefined && this.notYetAssingedList.length > 0) {
|
|
// var str=""
|
|
// this.notYetAssingedList.forEach(x => {
|
|
// str = str + x.employeeNoView + " " + x.employeeNameView ;
|
|
// });
|
|
// if (str)
|
|
// }
|
|
//}
|
|
|
|
var attnRequest: { fromDate: Date, toDate: Date, isWithEmployee: boolean, employeeID: number }[];
|
|
attnRequest = [];
|
|
|
|
|
|
attnRequest.push({ "fromDate": this.fromDate, "toDate": this.toDate, "isWithEmployee": true, "employeeID": 0 });
|
|
if (this.withEmployee) {
|
|
if (this.selectedEmployees != undefined && this.selectedEmployees.length > 0) {
|
|
attnRequest = [];
|
|
this.selectedEmployees.forEach(x => {
|
|
attnRequest.push({ "fromDate": this.fromDate, "toDate": this.toDate, "isWithEmployee": false, "employeeID": x.employeeID });
|
|
|
|
});
|
|
}
|
|
else {
|
|
this.notificationService.showWarning('Please Select Employee!');
|
|
return;
|
|
}
|
|
|
|
}
|
|
this.loadingPanel.ShowLoadingPanel = true;
|
|
|
|
this.attnService.dailyAttnProcessManual(attnRequest).subscribe(
|
|
(x) => {
|
|
|
|
},
|
|
(x) => {
|
|
this.loadingPanel.ShowLoadingPanel = false;
|
|
this.notificationService.showError(x.error);
|
|
console.log(x.error);
|
|
this.processStatus = x.error;
|
|
},
|
|
() => {
|
|
this.loadingPanel.ShowLoadingPanel = false;
|
|
this.notificationService.showSuccess("Attendance process completed successfully.");
|
|
this.processStatus = "Attendance Process is completed successfully.";
|
|
});
|
|
}
|
|
|
|
public checkBoxChange() {
|
|
debugger
|
|
if (this.withEmployee) {
|
|
this.withEmployee = false;
|
|
this.selectedEmployees = [];
|
|
}
|
|
else
|
|
this.withEmployee = true;
|
|
|
|
}
|
|
}
|