227 lines
9.1 KiB
TypeScript
227 lines
9.1 KiB
TypeScript
import { Component, Input, OnInit, ChangeDetectionStrategy } from "@angular/core";
|
|
import {
|
|
GridDataResult, PageChangeEvent, SelectableSettings,
|
|
DataStateChangeEvent
|
|
} from '@progress/kendo-angular-grid';
|
|
import { process, State } from "@progress/kendo-data-query";
|
|
import { AttendanceRegularizationDTO } from '../../../_models/Attendance/attendanceRegularizationDTO';
|
|
import { EmployeeServices } from '../../../_services/employee/employee.service';
|
|
import { AttendanceServices } from '../../../_services/attendance/attendance.service';
|
|
import { ApiService } from '../../../app.api.service';
|
|
import { HRMNotificationService } from '../../../app.notification.service';
|
|
import { DataTransferService } from '../../../data.transfer.service';
|
|
import { AppWindowPopUp } from '../../../app.windowPopup.service';
|
|
import { UntilityHandlerService } from '../../../utility.hanldler.service';
|
|
import { loadingPanelService } from '../../../hrm-loding panel/loding.panel.service';
|
|
import { EnumAttendanceType, EnumExtension, EnumWFAttnStatus } from '../../../_models/enums';
|
|
import { Shift } from '../../../_models/Attendance/shift';
|
|
import { DailyAttnProcess } from '../../../_models/Attendance/dailyAttnProcess';
|
|
import { CommonModule } from '@angular/common';
|
|
import { ButtonModule } from '@progress/kendo-angular-buttons';
|
|
import { DropDownListModule } from '@progress/kendo-angular-dropdowns';
|
|
import { ReactiveFormsModule } from '@angular/forms';
|
|
import { FormsModule } from '@angular/forms';
|
|
|
|
import { KENDO_GRID } from '@progress/kendo-angular-grid';
|
|
import { DatePickerModule } from '@progress/kendo-angular-dateinputs';
|
|
@Component({
|
|
selector: 'app-attendance-regularize-approve-details',
|
|
templateUrl: './attendance-regularize-approve-details.component.html',
|
|
styleUrls: ['./attendance-regularize-approve-details.component.css']
|
|
,changeDetection: ChangeDetectionStrategy.Eager,
|
|
standalone: false,
|
|
|
|
})
|
|
export class AttendanceRegularizeApproveDetailsComponent implements OnInit {
|
|
public state: State = {
|
|
skip: 0,
|
|
take: 10
|
|
};
|
|
public gridView: GridDataResult;
|
|
AttendanceRegularizationDTOsTemp: AttendanceRegularizationDTO[];
|
|
AttendanceRegularizationDTOsForGrid1: AttendanceRegularizationDTO[];
|
|
statusList = [
|
|
{ id: 1, name: 'Present' },
|
|
{ id: 2, name: 'Absent' },
|
|
{ id: 7, name: 'Out-Side-Duty' },
|
|
]; // any = EnumExtension.getNamesAndValues(EnumAttendanceType);
|
|
@Input() public employeeId: number;
|
|
@Input() public shifts: Shift[];
|
|
@Input() public dailtyAtts: DailyAttnProcess[];
|
|
|
|
public empAttnData: DailyAttnProcess[];
|
|
constructor(public apiService: ApiService,
|
|
public attendanceServices: AttendanceServices,
|
|
public notificationService: HRMNotificationService,
|
|
public loadingPanel: loadingPanelService) { }
|
|
|
|
ngOnInit() {
|
|
this.onSearch();
|
|
}
|
|
|
|
|
|
private onSearch() {
|
|
|
|
this.empAttnData = this.dailtyAtts.filter(x => x.employeeID == this.employeeId);
|
|
this.empAttnData.forEach(x => {
|
|
x.inTime = new Date(x.actualInTime);
|
|
x.outTime = new Date(x.actualOutTime);
|
|
x.shiftID = x.actualShiftID;
|
|
});
|
|
//this.AttendanceRegularizationDTOsTemp = [];
|
|
//this.attendanceServices.getDailyAttnProcessByEmpIdandWFStatus(data).subscribe(
|
|
// (resp) => {
|
|
// this.AttendanceRegularizationDTOsTemp = resp;
|
|
// },
|
|
// (err) => {
|
|
// this.loadingPanel.ShowLoadingPanel = false;
|
|
// this.notificationService.showError(err.error);
|
|
// },
|
|
// () => {
|
|
// this.AttendanceRegularizationDTOsForGrid1 = [];
|
|
// if (this.AttendanceRegularizationDTOsTemp && this.AttendanceRegularizationDTOsTemp.length > 0) {
|
|
// this.AttendanceRegularizationDTOsTemp.forEach(x => {
|
|
// let AttendanceRegularizationDTO2: AttendanceRegularizationDTO = new AttendanceRegularizationDTO();
|
|
// AttendanceRegularizationDTO2 = x;
|
|
// AttendanceRegularizationDTO2.inTime = x.inTime ? new Date(x.inTime) : undefined;
|
|
// AttendanceRegularizationDTO2.outTime = x.outTime ? new Date(x.outTime) : undefined;
|
|
// this.AttendanceRegularizationDTOsForGrid1.push(AttendanceRegularizationDTO2);
|
|
// });
|
|
// }
|
|
// this.loadNotSubmittedGrid();
|
|
// this.loadingPanel.ShowLoadingPanel = false;
|
|
// }
|
|
//);
|
|
}
|
|
loadNotSubmittedGrid() {
|
|
this.gridView = process(this.AttendanceRegularizationDTOsForGrid1, this.state);
|
|
}
|
|
public dataStateChange(state: DataStateChangeEvent): void {
|
|
this.state = state;
|
|
this.gridView = process(this.AttendanceRegularizationDTOsForGrid1, this.state);
|
|
}
|
|
|
|
|
|
|
|
editHandler({ dataItem }) {
|
|
var item: DailyAttnProcess = dataItem;
|
|
;
|
|
|
|
if (item.lmRemarks == undefined || item.lmRemarks == '') {
|
|
this.notificationService.showWarning("Please Enter Comments")
|
|
return;
|
|
}
|
|
|
|
if (item.attenType == EnumAttendanceType.Absent) {
|
|
if (!confirm("Attendance status is absent, are you sure.")) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
var tempInTime: Date = item.inTime;
|
|
var tempoutTime: Date = item.outTime;
|
|
var tempShiftID: number = item.shiftID;
|
|
let tempItem: DailyAttnProcess = Object.assign({}, item);
|
|
|
|
tempItem.inTime = tempItem.actualInTime;
|
|
tempItem.outTime = tempItem.actualOutTime;
|
|
tempItem.shiftID = tempItem.actualShiftID;
|
|
|
|
tempItem.actualInTime = tempInTime;
|
|
tempItem.actualOutTime = tempoutTime;
|
|
tempItem.actualShiftID = tempShiftID;
|
|
tempItem.isLate = false;
|
|
tempItem.lateHour = 0;
|
|
tempItem.earlyHour = 0;
|
|
tempItem.isManualEntry = true;
|
|
tempItem.wfStatus = EnumWFAttnStatus.LMApproved;
|
|
this.update(tempItem);
|
|
}
|
|
|
|
update(item: DailyAttnProcess) {
|
|
this.loadingPanel.ShowLoadingPanel = true;
|
|
this.attendanceServices.updateAttendanceRegularizationForApprove(item).subscribe(
|
|
(resp) => {
|
|
|
|
},
|
|
(err) => {
|
|
this.loadingPanel.ShowLoadingPanel = false;
|
|
this.notificationService.showError(err.error);
|
|
|
|
},
|
|
() => {
|
|
this.loadingPanel.ShowLoadingPanel = false;
|
|
|
|
var index = this.empAttnData.findIndex(x => x.employeeID == item.employeeID && x.attnDate == item.attnDate);
|
|
this.empAttnData.splice(index, 1);
|
|
var index = this.dailtyAtts.findIndex(x => x.employeeID == item.employeeID && x.attnDate == item.attnDate);
|
|
this.dailtyAtts.splice(index, 1);
|
|
this.notificationService.showSuccess("Data Updated successfully.");
|
|
}
|
|
);
|
|
}
|
|
|
|
RejectHandler({ dataItem }) {
|
|
|
|
var item: DailyAttnProcess = dataItem;
|
|
|
|
if (item.lmRemarks == undefined || item.lmRemarks == '') {
|
|
this.notificationService.showWarning("Please Enter Comments")
|
|
return;
|
|
}
|
|
|
|
|
|
var saveItem: DailyAttnProcess = new DailyAttnProcess();
|
|
saveItem.attnDate = item.attnDate;
|
|
saveItem.employeeID = item.employeeID;
|
|
saveItem.lmRemarks = item.lmRemarks;
|
|
saveItem.isManualEntry = true;
|
|
saveItem.wfStatus = EnumWFAttnStatus.Reject;
|
|
|
|
|
|
this.loadingPanel.ShowLoadingPanel = true;
|
|
this.attendanceServices.RejectAttnStatusByLM(saveItem).subscribe(
|
|
(resp) => {
|
|
|
|
},
|
|
(err) => {
|
|
this.loadingPanel.ShowLoadingPanel = false;
|
|
this.notificationService.showError(err.error);
|
|
|
|
},
|
|
() => {
|
|
this.loadingPanel.ShowLoadingPanel = false;
|
|
|
|
var index = this.empAttnData.findIndex(x => x.employeeID == saveItem.employeeID && x.attnDate == item.attnDate);
|
|
this.empAttnData.splice(index, 1);
|
|
var index = this.dailtyAtts.findIndex(x => x.employeeID == saveItem.employeeID && x.attnDate == item.attnDate);
|
|
this.dailtyAtts.splice(index, 1);
|
|
this.notificationService.showSuccess("Request Rejected successfully.");
|
|
}
|
|
);
|
|
|
|
// this.update(item);
|
|
}
|
|
|
|
onShiftChange(shiftId: any, dap: DailyAttnProcess) {
|
|
let shift = this.shifts.find(x => x.id === shiftId);
|
|
//console.log(value2);
|
|
if (shift !== undefined) {
|
|
let shiftInTime = new Date(shift.inTime);
|
|
let inMinute = shiftInTime.getMinutes();
|
|
let inHour = shiftInTime.getHours();
|
|
|
|
let shiftOutTime = new Date(shift.outTime);
|
|
let outMinute = shiftOutTime.getMinutes();
|
|
let outHour = shiftOutTime.getHours();
|
|
|
|
let dapInTime = new Date(dap.inTime);
|
|
let dapOutTime = new Date(dap.outTime);
|
|
|
|
dap.inTime = new Date(dapInTime.getFullYear(), dapInTime.getMonth(), dapInTime.getDate(), inHour, inMinute);
|
|
dap.outTime = new Date(dapOutTime.getFullYear(), dapOutTime.getMonth(), dapOutTime.getDate(), outHour, outMinute);
|
|
|
|
}
|
|
}
|
|
}
|