diff --git a/Mohem/src/app/attendance-tracking/home/home.component.ts b/Mohem/src/app/attendance-tracking/home/home.component.ts index 422355c2..276b32ab 100644 --- a/Mohem/src/app/attendance-tracking/home/home.component.ts +++ b/Mohem/src/app/attendance-tracking/home/home.component.ts @@ -1,9 +1,9 @@ -import { Component, OnInit } from '@angular/core'; +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', @@ -18,7 +18,8 @@ export class HomeComponent implements OnInit { constructor( public cs:CommonService, public db:DashboredService, - public ts:TranslatorService + public ts:TranslatorService, + public AttendScanService:AttendScanService ) { } ngOnInit() { @@ -26,13 +27,6 @@ export class HomeComponent implements OnInit { this.cuurentDate = new Date(); this.direction = TranslatorService.getCurrentLanguageName(); this.cuurentDate =this.getHeaderDate(this.cuurentDate); - //**condition to check is checkout or not to display PUSE Button** - // if(ischeckOutP_REMAINING_HOURS){ - // this.checkOut=true; - // }else{ - // this.checkOut=false; - // } - } // call services @@ -52,7 +46,7 @@ export class HomeComponent implements OnInit { 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 ==='00:00'){ + if(this.attendanceTrackingList.P_REMAINING_HOURS ==='0'){ this.isCheckOut=true; }else{ this.isCheckOut=false; @@ -78,6 +72,7 @@ openDialog(){ () => { //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'), diff --git a/Mohem/src/app/hmg-common/hmg-common.module.ts b/Mohem/src/app/hmg-common/hmg-common.module.ts index 1c05a6ed..a3acc824 100644 --- a/Mohem/src/app/hmg-common/hmg-common.module.ts +++ b/Mohem/src/app/hmg-common/hmg-common.module.ts @@ -98,6 +98,9 @@ import {ConfirmLoginComponent} from '../authentication/confirm-login/confirm-log import {WelcomeComponent} from './ui/welcome-login/welcome.component' import {DashboredService} from './services/dashbored/dashbored.service' import {FabButtonComponent} from './ui/fab-button/fab-button.component' +import { AttendScanService } from './services/attend-services/attend-scan.service'; +import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx'; + @NgModule({ imports: [ CommonModule, @@ -228,6 +231,7 @@ import {FabButtonComponent} from './ui/fab-button/fab-button.component' ConfirmLoginComponent ], providers: [ + AttendScanService, DashboredService, ConnectorService, TranslatorService, @@ -261,7 +265,9 @@ import {FabButtonComponent} from './ui/fab-button/fab-button.component' Camera, File, MenuService, - OpenNativeSettings + OpenNativeSettings, + BarcodeScanner, + ] }) export class HmgCommonModule { } diff --git a/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.spec.ts b/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.spec.ts new file mode 100644 index 00000000..b38b6ba2 --- /dev/null +++ b/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { AttendScanService } from './attend-scan.service'; + +describe('AttendScanService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: AttendScanService = TestBed.get(AttendScanService); + expect(service).toBeTruthy(); + }); +}); diff --git a/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.ts b/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.ts new file mode 100644 index 00000000..dc780d83 --- /dev/null +++ b/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.ts @@ -0,0 +1,123 @@ +import { Injectable } from '@angular/core'; +// import { DevicePermissionsService } from '../device-permissions/device-permissions.service'; +import { DomSanitizer } from '@angular/platform-browser'; +import { SharedDataService } from '../shared-data-service/shared-data.service'; +import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx'; +import { AttendanceService } from 'src/app/home/services/attendance.services'; +import { ZBar } from '@ionic-native/zbar/ngx'; +import { Geolocation } from "@ionic-native/geolocation/ngx"; +import { attendanceSwipeScannerRequest } from 'src/app/home/models/attendanceSwipe.Request'; +import { AuthenticatedUser } from '../authentication/models/authenticated-user'; +import { CommonService } from '../common/common.service'; +import { TranslatorService } from '../translator/translator.service'; +import { Response } from "src/app/hmg-common/services/models/response"; +import { Camera, CameraOptions,PictureSourceType} from "@ionic-native/Camera/ngx"; +import { DevicePermissionsService } from '../../services/device-permissions/device-permissions.service' +import { Device } from "@ionic-native/device/ngx"; + + +@Injectable({ + providedIn: 'root' +}) +export class AttendScanService { + location: boolean; + camera: boolean; + lat: any; + longt: any; + deviceID: string; + scannedResult: any; + userData: any = {}; + constructor(private device: Device, + private zbar: ZBar, + private geolocation: Geolocation, + private attendance_service: AttendanceService, + private barcodeScanner: BarcodeScanner, + private cameraController: Camera, + public sharedData: SharedDataService, + private sanitizer: DomSanitizer, + private permissions: DevicePermissionsService, + public common:CommonService, + public ts: TranslatorService,) { + this.userData =this.common.sharedService.getSharedData(AuthenticatedUser.SHARED_DATA,false); + } + + public getDeviceLocation() { + let isVirtual = this.device.isVirtual; + if(isVirtual==true){ + alert("emulater>>>>>>>"+isVirtual); + alert("You are using virtual device"); + return false; + } + + this.permissions.requestLocationAutherization().then(granted => { + this.location = granted as boolean; + if (this.location) { + this.geolocation + .getCurrentPosition({ maximumAge: 3000, timeout: 10000, enableHighAccuracy: true }) + .then(resp => { + // console.log(resp.coords.latitude); + // console.log(resp.coords.longitude); + this.lat = resp.coords.latitude; + this.longt = resp.coords.longitude; + this.attendance(); + }) + .catch(error => { + console.log("Error getting location", error); + }); + + } else { + return false; + } + }); + + } + + public attendance() { + this.permissions.requestCameraAutherization().then(granted => { + this.camera = granted as boolean; + if (this.camera) { + this.scanCode(); + } + } + ); + } + + + public scanCode() { + this.barcodeScanner.scan().then(barcodeData => { + console.log('Barcode data', barcodeData); + // let strResult = JSON.parse(barcodeData); + // console.log(strResult.QRValue); + this.scannedResult = barcodeData; + this.deviceID = this.device.uuid; + this.swipeAttendance(); + }).catch(err => { + console.log('Error', err); + }); + } + + + public swipeAttendance() { + let request: attendanceSwipeScannerRequest = new attendanceSwipeScannerRequest(); + request.Latitude = this.lat; + request.Longitude = this.longt; + request.QRValue = this.scannedResult.text; + request.UID = this.deviceID; + request.UserName = this.userData.EMPLOYEE_NUMBER; + console.log("request"); + console.log(JSON.stringify(request)); + this.attendance_service + .attendanceSwipeScanner(request, () => { + console.log("Error inside in swipe attendance"); + }) + .subscribe((result: Response) => { + if (this.common.validResponse(result)) { + console.log("response"); + console.log(result); + this.common.presentAlert(this.ts.trPK("home", "swipeAlertSuccess")); + } else { + this.common.presentAlert(this.ts.trPK("home", "swipeAlertFailed")); + } + }); + } +} diff --git a/Mohem/src/app/home/home.page.ts b/Mohem/src/app/home/home.page.ts index 50f2ccab..1130fd14 100644 --- a/Mohem/src/app/home/home.page.ts +++ b/Mohem/src/app/home/home.page.ts @@ -395,6 +395,10 @@ export class HomePage implements OnInit { } } + parentFn($event: string) { + console.log($event); // this will output 'hello from child' + } + private Change_password() { this.common.openChangePassword(); } diff --git a/Mohem/src/theme/styles.scss b/Mohem/src/theme/styles.scss index ba2b189c..f4c224f2 100644 --- a/Mohem/src/theme/styles.scss +++ b/Mohem/src/theme/styles.scss @@ -279,6 +279,7 @@ ion-datetime.datetime.datetime-ios.ng-valid.ng-dirty.ng-touched { .alert-md .alert-head,.alert-ios .alert-head{ background-color:var(--grayBG); color: var(--light); + } /********profile grid************/ // .profile-grid{ @@ -971,3 +972,23 @@ border:0px .slideFullWidth .swiper-container .swiper-wrapper .swiper-slide:first-child { margin-left:15px; } +.alert-button-group.sc-ion-alert-md, +.alert-button.sc-ion-alert-ios { + text-align: center; +} + + +.alert-message.sc-ion-alert-md, +.alert-message.sc-ion-alert-ios, +.alert-sub-title.sc-ion-alert-md, +.alert-title.sc-ion-alert-md, +.alert-sub-title.sc-ion-alert-ios, +.alert-title.sc-ion-alert-ios { + + text-align: center; +} + +.alert-button-inner.sc-ion-alert-md { + + justify-content: center !important; +}