import { Component, OnInit, EventEmitter, Output } from '@angular/core'; import { CommonService } from "src/app/hmg-common/services/common/common.service"; import { DashboredService } from 'src/app/hmg-common/services/dashbored/dashbored.service'; 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'; @Component({ selector: 'app-home', templateUrl: './home.component.html', styleUrls: ['./home.component.scss'], }) export class HomeComponent implements OnInit { attendanceTrackingList:any =[]; cuurentDate:any; direction: string; isCheckOut:boolean= false; constructor( public cs:CommonService, public db:DashboredService, public ts:TranslatorService, public AttendScanService:AttendScanService ) { } ngOnInit() { this.attendanceTracking(); this.cuurentDate = new Date(); this.direction = TranslatorService.getCurrentLanguageName(); this.cuurentDate =this.getHeaderDate(this.cuurentDate); } // call services public attendanceTracking(){ this.db.getAttendanceTracking(()=> {},this.ts.trPK('general', 'retry')).subscribe( (result)=>{ console.log("result: "+result); this.handleRespondGetAttendanceTracking(result); } ) } public handleRespondGetAttendanceTracking(result){ if (this.cs.validResponse(result)) { if(result.GetAttendanceTrackingList != null){ this.attendanceTrackingList=result.GetAttendanceTrackingList; //**condition to check is checkout or not to display PUSE Button** if(this.attendanceTrackingList.P_REMAINING_HOURS !='0'){ this.isCheckOut=true; }else{ this.isCheckOut=false; } } } } getHeaderDate(date: any) { if (this.direction == "en") { return this.cs.getMonthName(date.getMonth() + 1) + ", " + date.getDate() +" "+ date.getFullYear(); } else { return this.cs.getMonthNameAr(date.getMonth() + 1) + ", " + date.getDate() +" "+ date.getFullYear(); } } openDialog(){ this.cs.confirmAlertDialogAttendance( () => { //to open scan(); //this.cs.openScan(); this.AttendScanService.getDeviceLocation(); }, this.ts.trPK('general', 'ok'), () => {}, this.ts.trPK('general', 'cancel'), this.ts.trPK('vacation-rule', 'confirmation'), this.ts.trPK('attendance-tracking', 'confirm-alert3') + "
"+"
"+ this.ts.trPK('attendance-tracking', 'confirm-alert1') + this.ts.trPK('attendance-tracking', 'confirm-alert2') ); } }// end home