From a78477c1922534c711b9b2c57333dc4650c093be Mon Sep 17 00:00:00 2001 From: umasoodch Date: Tue, 18 Feb 2020 17:37:25 +0300 Subject: [PATCH] fixed attendance tracking issue --- .../services/accrual.service.ts | 12 +-- .../home/home.component.ts | 12 ++- .../authentication/authentication.service.ts | 1 - .../services/dashbored/dashbored.service.ts | 4 +- Mohem/src/app/home/home.page.html | 88 ------------------- Mohem/src/app/home/home.page.ts | 59 +++++++------ 6 files changed, 49 insertions(+), 127 deletions(-) diff --git a/Mohem/src/app/accrual-balances/services/accrual.service.ts b/Mohem/src/app/accrual-balances/services/accrual.service.ts index 6e063d3e..c7b6c198 100644 --- a/Mohem/src/app/accrual-balances/services/accrual.service.ts +++ b/Mohem/src/app/accrual-balances/services/accrual.service.ts @@ -1,13 +1,13 @@ -import { Injectable } from "@angular/core"; -import { Observable } from "rxjs"; -import { ConnectorService } from "src/app/hmg-common/services/connector/connector.service"; -import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service"; +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { ConnectorService } from 'src/app/hmg-common/services/connector/connector.service'; +import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service'; @Injectable({ - providedIn: "root" + providedIn: 'root' }) export class AccrualService { public static GET_ACCRUAL_BALANCE = - "Services/ERP.svc/REST/GET_ACCRUAL_BALANCES"; + 'Services/ERP.svc/REST/GET_ACCRUAL_BALANCES'; constructor( public con: ConnectorService, public authService: AuthenticationService diff --git a/Mohem/src/app/attendance-tracking/home/home.component.ts b/Mohem/src/app/attendance-tracking/home/home.component.ts index d2070095..a02ea816 100644 --- a/Mohem/src/app/attendance-tracking/home/home.component.ts +++ b/Mohem/src/app/attendance-tracking/home/home.component.ts @@ -4,6 +4,9 @@ import { DashboredService } from 'src/app/hmg-common/services/dashbored/dashbore import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; import {AttendScanService} from '../../hmg-common/services/attend-services/attend-scan.service'; import { AttendanceTrackingResponse } from 'src/app/hmg-common/services/dashbored/attendance-tracking.response'; +import { SharedDataService } from '../../hmg-common/services/shared-data-service/shared-data.service'; +import { AuthenticatedUser } from 'src/app/hmg-common/services/authentication/models/authenticated-user'; + @Component({ selector: 'app-home', templateUrl: './home.component.html', @@ -22,11 +25,13 @@ export class HomeComponent implements OnInit { public isCheckedIn = undefined; public displayTime: any; public percent: any; + public userData = this.sharedData.getSharedData(AuthenticatedUser.SHARED_DATA, false); constructor( public cs: CommonService, public db: DashboredService, public ts: TranslatorService, - public attendScanService: AttendScanService + public attendScanService: AttendScanService, + public sharedData: SharedDataService ) { } ngOnInit() { @@ -96,7 +101,10 @@ export class HomeComponent implements OnInit { } showAttendanceTracking() { - this.db.getAttendanceTracking() .subscribe((result: AttendanceTrackingResponse) => { + const request = { + P_SELECTED_EMPLOYEE_NUMBER: this.userData.EMPLOYEE_NUMBER + }; + this.db.getAttendanceTracking(request).subscribe((result: AttendanceTrackingResponse) => { if (this.cs.validResponse(result)) { const key = 'GetAttendanceTrackingList'; this.convertAndAssignTime(result[key]); diff --git a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts index 1e615403..1d437267 100644 --- a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts +++ b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts @@ -107,7 +107,6 @@ export class AuthenticationService { request.P_USER_NAME = user.EMPLOYEE_NUMBER; request.UserName = user.EMPLOYEE_NUMBER; request.P_EMAIL_ADDRESS = user.EMPLOYEE_EMAIL_ADDRESS; - if (AuthenticationService.requireRelogin) { this.sessionTimeOutDialog(); } diff --git a/Mohem/src/app/hmg-common/services/dashbored/dashbored.service.ts b/Mohem/src/app/hmg-common/services/dashbored/dashbored.service.ts index 21fc550f..587aeee6 100644 --- a/Mohem/src/app/hmg-common/services/dashbored/dashbored.service.ts +++ b/Mohem/src/app/hmg-common/services/dashbored/dashbored.service.ts @@ -66,8 +66,8 @@ export class DashboredService { oerrorLable ); } -public getAttendanceTracking(onError ?: any ,oerrorLable ?: any): Observable{ - const request = new Request(); +public getAttendanceTracking(selectedEmployee: any, onError ?: any , oerrorLable ?: any): Observable{ + const request = selectedEmployee; this.authService.authenticateRequest(request); return this.con.post( DashboredService.attendancetrackingUrl, diff --git a/Mohem/src/app/home/home.page.html b/Mohem/src/app/home/home.page.html index 80bf9acd..7eb726f3 100644 --- a/Mohem/src/app/home/home.page.html +++ b/Mohem/src/app/home/home.page.html @@ -65,94 +65,6 @@ - - - - - - -
Time Left Today diff --git a/Mohem/src/app/home/home.page.ts b/Mohem/src/app/home/home.page.ts index 71df7498..c56a3766 100644 --- a/Mohem/src/app/home/home.page.ts +++ b/Mohem/src/app/home/home.page.ts @@ -15,7 +15,7 @@ import { attendanceSwipeScannerRequest } from './models/attendanceSwipe.Request' import { Response } from 'src/app/hmg-common/services/models/response'; import { AttendanceService } from './services/attendance.services'; import { LoginRequest } from '../hmg-common/services/authentication/models/login.request'; -import { FileUploaderComponent } from '../hmg-common/ui/file-uploader/file-uploader.component' +import { FileUploaderComponent } from '../hmg-common/ui/file-uploader/file-uploader.component'; import { Camera } from '@ionic-native/Camera/ngx'; import { File } from '@ionic-native/file/ngx'; import { DomSanitizer } from '@angular/platform-browser'; @@ -28,10 +28,10 @@ import { PerformanceAppraisalResponse } from '../hmg-common/services/dashbored/p import { AttendanceTrackingResponse } from '../hmg-common/services/dashbored/attendance-tracking.response'; import { OpenPeriodDatesResponse } from '../hmg-common/services/dashbored/models/openPeriodDatesResponse'; import { GetSubordinatesAttdStatusRequest } from '../hmg-common/services/dashbored/models/GetSubordinatesAttdStatusRequest'; -import { GetSubordinatesLeavesRequest } from '../hmg-common/services/dashbored/models/GetSubordinatesLeavesRequest' -import { GetOpenNotificationsResponse } from '../hmg-common/services/dashbored/models/GetOpenNotificationsResponse' -import { GetSubordinatesAttdStatusResponse } from '../hmg-common/services/dashbored/models/GetSubordinatesAttdStatusResponse' -import { GetSubordinatesLeavesResponse } from '../hmg-common/services/dashbored/models/GetSubordinatesLeavesResponse' +import { GetSubordinatesLeavesRequest } from '../hmg-common/services/dashbored/models/GetSubordinatesLeavesRequest'; +import { GetOpenNotificationsResponse } from '../hmg-common/services/dashbored/models/GetOpenNotificationsResponse'; +import { GetSubordinatesAttdStatusResponse } from '../hmg-common/services/dashbored/models/GetSubordinatesAttdStatusResponse'; +import { GetSubordinatesLeavesResponse } from '../hmg-common/services/dashbored/models/GetSubordinatesLeavesResponse'; import { AccrualService } from '../accrual-balances/services/accrual.service'; import { GetDayAndHoursDetailsRequest } from '../time-card/service/models/get-day-hours-type-details.request'; import * as moment from 'moment'; @@ -125,7 +125,7 @@ export class HomePage implements OnInit { public displayTime: any; public menuEntries: any; public percent: any; -/////////////////////////////////TIME AND DATE VALUES/////////////////////////////// +///////////////////////////////// TIME AND DATE VALUES/////////////////////////////// public monthName: any; public yearDate: any; public selEmp: string; @@ -138,9 +138,9 @@ public selectedShiftFilter: any; public arrDaysAttendance: any = []; public arrDaysAbsent: any = []; public arrDaysOff: any = []; -public arrFutrueDays: any =[]; +public arrFutrueDays: any = []; -///////////////////////////////END////////////////////////////////////////////////// +/////////////////////////////// END////////////////////////////////////////////////// constructor( public ts: TranslatorService, public menu: MenuController, @@ -162,9 +162,9 @@ public arrFutrueDays: any =[]; private permissions: DevicePermissionsService, public DS: DashboredService, public accrualService: AccrualService, - ////////////////////////////////////////TIME AND DATE//////////////////////////// + //////////////////////////////////////// TIME AND DATE//////////////////////////// public timeCardService: TimeCardService - /////////////////////END///////////////////////////////////////////////////////// + ///////////////////// END///////////////////////////////////////////////////////// ) { this.events.subscribe('img-change', displayImg => { this.userImage = this.sanitizer.bypassSecurityTrustUrl('data:Image/*;base64,' + displayImg); @@ -526,16 +526,19 @@ convertAndAssignTime(data) { this.scheduledTime = this.convertInSeconds(data.P_SCHEDULED_HOURS.split(':')); this.isCheckedIn = this.remainingTime === this.scheduledTime ? false : true; this.initTimer(); - } +} showAttendanceTracking() { - this.DS.getAttendanceTracking().subscribe((result: AttendanceTrackingResponse) => { + const request = { + P_SELECTED_EMPLOYEE_NUMBER: this.userData.EMPLOYEE_NUMBER + }; + this.DS.getAttendanceTracking(request).subscribe((result: AttendanceTrackingResponse) => { if (this.common.validResponse(result)) { const key = 'GetAttendanceTrackingList'; this.convertAndAssignTime(result[key]); } }); - } +} openPeriodDateDashbored() { this.DS.getOpenPeriodDates(() => { console.log('Error '); }).subscribe((result: OpenPeriodDatesResponse) => { @@ -645,7 +648,7 @@ openStatsButton(link: string) { - //////calling time and date to load it in calendar/////// + ////// calling time and date to load it in calendar/////// public getDayHoursTypeDetails() { const dayAndHoursReqObj = new GetDayAndHoursDetailsRequest(); this.monthName = moment().format('MMMM'); @@ -693,39 +696,39 @@ openStatsButton(link: string) { countAllAttendDays(allDays) { for (let i = 0; i < allDays.length; i++) { - if (allDays[i].DAY_TYPE == "OFF") { - //offDay - this.arrDaysOff.push({startTime:new Date(allDays[i].SCHEDULE_DATE), + if (allDays[i].DAY_TYPE == 'OFF') { + // offDay + this.arrDaysOff.push({startTime: new Date(allDays[i].SCHEDULE_DATE), endTime: new Date(allDays[i].SCHEDULE_DATE)}); - } else if (allDays[i].DAY_TYPE == "SCHEDULED" && !allDays[i].REMARKS) { - //attendace + } else if (allDays[i].DAY_TYPE == 'SCHEDULED' && !allDays[i].REMARKS) { + // attendace this.arrDaysAttendance.push({startTime: new Date(allDays[i].SCHEDULE_DATE), endTime: new Date(allDays[i].SCHEDULE_DATE)}); - } else if(allDays[i].DAY_TYPE == "SCHEDULED" && allDays[i].REMARKS) { - //absent + } else if (allDays[i].DAY_TYPE == 'SCHEDULED' && allDays[i].REMARKS) { + // absent this.arrDaysAbsent.push( { startTime: new Date(allDays[i].SCHEDULE_DATE), endTime: new Date(allDays[i].SCHEDULE_DATE), - isoTime: "09:00:00", + isoTime: '09:00:00', allDay: false } ); - }else{ + } else { this.arrFutrueDays.push( { startTime: new Date(allDays[i].SCHEDULE_DATE), endTime: new Date(allDays[i].SCHEDULE_DATE), - isoTime: "09:00:00", + isoTime: '09:00:00', allDay: false } ); } } - this.common.sharedService.setSharedData(this.arrDaysOff,'calendarDayOffDateValue'); - this.common.sharedService.setSharedData(this.arrDaysAttendance,'calendarAttendanceDateValue'); - this.common.sharedService.setSharedData( this.arrDaysAbsent,'calendarDaysAbsentDateValue'); - this.common.sharedService.setSharedData( this.arrFutrueDays,'calendarDaysFutrueDateValue'); + this.common.sharedService.setSharedData(this.arrDaysOff, 'calendarDayOffDateValue'); + this.common.sharedService.setSharedData(this.arrDaysAttendance, 'calendarAttendanceDateValue'); + this.common.sharedService.setSharedData( this.arrDaysAbsent, 'calendarDaysAbsentDateValue'); + this.common.sharedService.setSharedData( this.arrFutrueDays, 'calendarDaysFutrueDateValue'); } }