diff --git a/Mohem/src/app/app-routing.module.ts b/Mohem/src/app/app-routing.module.ts
index 4e624a59..c0c8b679 100644
--- a/Mohem/src/app/app-routing.module.ts
+++ b/Mohem/src/app/app-routing.module.ts
@@ -1,26 +1,27 @@
-import { NgModule } from '@angular/core';
-import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
+import { NgModule } from '@angular/core';
+import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
+
+const routes: Routes = [
+ { path: '', redirectTo: 'authentication/login', pathMatch: 'full' },
+ {
+ path: 'authentication', loadChildren: './authentication/authentication.module#AuthenticationPageModule',
+ data: { preload: true, delay: 1000 }
+ },
+ { path: 'home', loadChildren: './home/home.module#HomePageModule' },
+ { path: 'profile', loadChildren: './profile/profile.module#ProfilePageModule' },
+ { path: 'vacation-rule', loadChildren: './vacation-rule/vacation-rule.module#VacationRulePageModule' },
+ { path: 'accrual-balances', loadChildren: './accrual-balances/accrual-balances.module#AccrualBalancesPageModule' },
{ path: 'attendance', loadChildren: './attendance/attendance.module#AttendancePageModule' }
-const routes: Routes = [
- { path: '', redirectTo: 'authentication/login', pathMatch: 'full' },
- {
- path: 'authentication', loadChildren: './authentication/authentication.module#AuthenticationPageModule',
- data: { preload: true, delay: 1000 }
- },
- { path: 'home', loadChildren: './home/home.module#HomePageModule' },
- { path: 'profile', loadChildren: './profile/profile.module#ProfilePageModule' },
- { path: 'vacation-rule', loadChildren: './vacation-rule/vacation-rule.module#VacationRulePageModule' },
- { path: 'accrual-balances', loadChildren: './accrual-balances/accrual-balances.module#AccrualBalancesPageModule' }
-
-
-
-
-];
-
-@NgModule({
- imports: [
- RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
- ],
- exports: [RouterModule]
-})
-export class AppRoutingModule { }
+
+
+
+
+];
+
+@NgModule({
+ imports: [
+ RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
+ ],
+ exports: [RouterModule]
+})
+export class AppRoutingModule { }
diff --git a/Mohem/src/app/app.module.ts b/Mohem/src/app/app.module.ts
index ff360cf4..f71d2085 100644
--- a/Mohem/src/app/app.module.ts
+++ b/Mohem/src/app/app.module.ts
@@ -9,6 +9,8 @@ import { StatusBar } from '@ionic-native/status-bar/ngx';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
+import { ZBar } from '@ionic-native/zbar/ngx';
+import { Geolocation } from '@ionic-native/geolocation/ngx';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
@@ -24,6 +26,8 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
providers: [
StatusBar,
SplashScreen,
+ ZBar,
+ Geolocation,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
diff --git a/Mohem/src/app/attendance/attendance.module.ts b/Mohem/src/app/attendance/attendance.module.ts
new file mode 100644
index 00000000..851b4691
--- /dev/null
+++ b/Mohem/src/app/attendance/attendance.module.ts
@@ -0,0 +1,33 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormsModule } from '@angular/forms';
+import { Routes, RouterModule } from '@angular/router';
+
+import { IonicModule } from '@ionic/angular';
+
+import { AttendancePage } from './attendance.page';
+import { HomeComponent } from './home/home.component';
+
+const routes: Routes = [
+ {
+ path: '',
+ component: AttendancePage,
+ children: [
+ {
+ path: 'home',
+ component: HomeComponent
+ }
+ ]
+ }
+];
+
+@NgModule({
+ imports: [
+ CommonModule,
+ FormsModule,
+ IonicModule,
+ RouterModule.forChild(routes)
+ ],
+ declarations: [AttendancePage, HomeComponent]
+})
+export class AttendancePageModule {}
diff --git a/Mohem/src/app/attendance/attendance.page.html b/Mohem/src/app/attendance/attendance.page.html
new file mode 100644
index 00000000..4991892d
--- /dev/null
+++ b/Mohem/src/app/attendance/attendance.page.html
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/Mohem/src/app/attendance/attendance.page.scss b/Mohem/src/app/attendance/attendance.page.scss
new file mode 100644
index 00000000..e69de29b
diff --git a/Mohem/src/app/attendance/attendance.page.spec.ts b/Mohem/src/app/attendance/attendance.page.spec.ts
new file mode 100644
index 00000000..11ce7e31
--- /dev/null
+++ b/Mohem/src/app/attendance/attendance.page.spec.ts
@@ -0,0 +1,27 @@
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { AttendancePage } from './attendance.page';
+
+describe('AttendancePage', () => {
+ let component: AttendancePage;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ AttendancePage ],
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(AttendancePage);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/Mohem/src/app/attendance/attendance.page.ts b/Mohem/src/app/attendance/attendance.page.ts
new file mode 100644
index 00000000..c62bc287
--- /dev/null
+++ b/Mohem/src/app/attendance/attendance.page.ts
@@ -0,0 +1,16 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+ selector: 'app-attendance',
+ templateUrl: './attendance.page.html',
+ styleUrls: ['./attendance.page.scss'],
+})
+export class AttendancePage implements OnInit {
+
+ constructor() { }
+
+ ngOnInit() {
+ }
+
+}
+
diff --git a/Mohem/src/app/attendance/home/home.component.html b/Mohem/src/app/attendance/home/home.component.html
new file mode 100644
index 00000000..036afd9c
--- /dev/null
+++ b/Mohem/src/app/attendance/home/home.component.html
@@ -0,0 +1,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Mohem/src/app/attendance/home/home.component.scss b/Mohem/src/app/attendance/home/home.component.scss
new file mode 100644
index 00000000..e69de29b
diff --git a/Mohem/src/app/attendance/home/home.component.spec.ts b/Mohem/src/app/attendance/home/home.component.spec.ts
new file mode 100644
index 00000000..5ec1377b
--- /dev/null
+++ b/Mohem/src/app/attendance/home/home.component.spec.ts
@@ -0,0 +1,27 @@
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { HomeComponent } from './home.component';
+
+describe('HomeComponent', () => {
+ let component: HomeComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ HomeComponent ],
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(HomeComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/Mohem/src/app/attendance/home/home.component.ts b/Mohem/src/app/attendance/home/home.component.ts
new file mode 100644
index 00000000..fd65ee92
--- /dev/null
+++ b/Mohem/src/app/attendance/home/home.component.ts
@@ -0,0 +1,51 @@
+import { Component, OnInit } from '@angular/core';
+import { Geolocation } from '@ionic-native/geolocation/ngx';
+import { ZBar, ZBarOptions } from '@ionic-native/zbar/ngx';
+
+@Component({
+ selector: 'app-home',
+ templateUrl: './home.component.html',
+ styleUrls: ['./home.component.scss'],
+})
+export class HomeComponent implements OnInit {
+
+ zbarOptions:any;
+ scannedResult:any;
+ lat : any;
+ longt : any;
+ constructor(private zbar: ZBar, private geolocation: Geolocation) {
+
+ this.zbarOptions = {
+ flash: 'off',
+ drawSight: false
+ }
+ console.log("your currnt location is");
+ this.geolocation.getCurrentPosition().then((resp) => {
+ // resp.coords.latitude
+ // resp.coords.longitude
+ console.log(resp.coords.latitude);
+ console.log(resp.coords.longitude);
+ }).catch((error) => {
+ console.log('Error getting location', error);
+ });
+ this.scanCode();
+ }
+
+ ngOnInit() {}
+
+ onClick()
+ {
+ this.scanCode();
+ }
+
+ scanCode(){
+ this.zbar.scan(this.zbarOptions)
+ .then(result => {
+ console.log(result); // Scanned code
+ this.scannedResult = result;
+ })
+ .catch(error => {
+ alert(error); // Error message
+ });
+ }
+}
diff --git a/Mohem/src/app/attendance/services/attendance.service.ts b/Mohem/src/app/attendance/services/attendance.service.ts
new file mode 100644
index 00000000..e69de29b
diff --git a/Mohem/src/app/authentication/change-password/change-password.component.html b/Mohem/src/app/authentication/change-password/change-password.component.html
index 4708cb63..f8e57774 100644
--- a/Mohem/src/app/authentication/change-password/change-password.component.html
+++ b/Mohem/src/app/authentication/change-password/change-password.component.html
@@ -1,7 +1,7 @@
diff --git a/Mohem/src/app/hmg-common/services/connector/connector.service.ts b/Mohem/src/app/hmg-common/services/connector/connector.service.ts
index 4e0c6ddd..59052827 100644
--- a/Mohem/src/app/hmg-common/services/connector/connector.service.ts
+++ b/Mohem/src/app/hmg-common/services/connector/connector.service.ts
@@ -121,6 +121,7 @@ export class ConnectorService {
if (!this.cs.validResponse(result)) {
// not authorized
console.log(result.MessageStatus);
+ console.log("erroe")
if (result.ErrorType === 2) {
//console.log("error expired");
} else {
diff --git a/Mohem/src/app/home/home.page.ts b/Mohem/src/app/home/home.page.ts
index f7ea5249..2649f990 100644
--- a/Mohem/src/app/home/home.page.ts
+++ b/Mohem/src/app/home/home.page.ts
@@ -6,6 +6,12 @@ import { AuthenticatedUser } from "src/app/hmg-common/services/authentication/mo
import { MenuService } from "src/app/hmg-common/services/menu/menuservice.service";
import { MenuResponse } from "src/app/hmg-common/services/menu/models/menu-response";
import { CommonService } from "src/app/hmg-common/services/common/common.service";
+import { Geolocation } from '@ionic-native/geolocation/ngx';
+import { ZBar, ZBarOptions } from '@ionic-native/zbar/ngx';
+import { Device } from '@ionic-native/device/ngx';
+import { attendanceSwipeScannerRequest } from './models/attendanceSwipe.Request';
+import { Response } from "src/app/hmg-common/services/models/response";
+import { AttendanceService } from './services/attendance.services';
@Component({
selector: "app-home",
@@ -16,18 +22,49 @@ export class HomePage implements OnInit {
userData: any = {};
user_image: any = "../assets/imgs/profile.png";
menuList: any = [];
+ zbarOptions:any;
+ scannedResult:any;
+ lat : any;
+ longt : any;
+ deviceID: string;
constructor(
public ts: TranslatorService,
public menu: MenuController,
public authService: AuthenticationService,
public menuService: MenuService,
public common: CommonService,
- public events:Events
- ) {}
+ public events:Events,
+ private device: Device,
+ private zbar: ZBar,
+ private geolocation: Geolocation,
+ private attendance_service:AttendanceService
+ ) {
+
+ }
ngOnInit() {
this.getUserDetails();
this.getMenu();
+ this.geolocation.getCurrentPosition().then((resp) => {
+ // resp.coords.latitude
+ // resp.coords.longitude
+ console.log(resp.coords.latitude);
+ console.log(resp.coords.longitude);
+ }).catch((error) => {
+ console.log('Error getting location', error);
+ });
+ }
+
+ ionViewDidLoad()
+ {
+ this.geolocation.getCurrentPosition().then((resp) => {
+ // resp.coords.latitude
+ // resp.coords.longitude
+ console.log(resp.coords.latitude);
+ console.log(resp.coords.longitude);
+ }).catch((error) => {
+ console.log('Error getting location', error);
+ });
}
private openMenu() {
this.menu.toggle();
@@ -68,4 +105,52 @@ export class HomePage implements OnInit {
private Change_password(){
this.common.openChangePassword();
}
+ private attendance(){
+ this.zbarOptions = {
+ flash: 'off',
+ drawSight: false
+ }
+ console.log("your currnt location is");
+
+ this.scanCode();
+ }
+
+ scanCode(){
+ this.zbar.scan(this.zbarOptions)
+ .then(result => {
+ console.log(result); // Scanned code
+ let strResult = JSON.parse(result);
+ console.log(strResult.QRValue);
+ this.scannedResult = result;
+ this.deviceID = this.device.uuid;
+ this.swipeAttendance();
+ })
+ .catch(error => {
+ alert(error); // Error message
+ });
+ }
+
+ swipeAttendance(){
+ let request: attendanceSwipeScannerRequest = new attendanceSwipeScannerRequest();
+ request.Latitude = this.lat;
+ request.Longitude = this.longt;
+ request.QRValue = this.scannedResult;
+ 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/models/attendanceSwipe.Request.ts b/Mohem/src/app/home/models/attendanceSwipe.Request.ts
new file mode 100644
index 00000000..036f065b
--- /dev/null
+++ b/Mohem/src/app/home/models/attendanceSwipe.Request.ts
@@ -0,0 +1,23 @@
+import { Request } from 'src/app/hmg-common/services/models/request';
+
+export class attendanceSwipeScannerRequest extends Request{
+ public static SHARED_DATA = 'attendanceSwipeScanner-request';
+ public P_USER_NAME:string;
+ public P_PASSWORD: string;
+ public UserName: string;
+ public CompanyID:number;
+ public BranchID: number;
+ public UID:string;
+ public Latitude:number;
+ public Longitude:number;
+ public QRValue: string;
+ public MemberID:number;
+ public EmployeeID: number;
+ public IPAdress: string;
+ public UserID: string;
+}
+
+
+
+
+
diff --git a/Mohem/src/app/home/services/attendance.services.ts b/Mohem/src/app/home/services/attendance.services.ts
new file mode 100644
index 00000000..9c0e71d0
--- /dev/null
+++ b/Mohem/src/app/home/services/attendance.services.ts
@@ -0,0 +1,20 @@
+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 { attendanceSwipeScannerRequest } from '../models/attendanceSwipe.Request';
+@Injectable({
+ providedIn: "root"
+})
+export class AttendanceService {
+ public AttendanceSwipeURL : string ='Services/SWP.svc/REST/AuthenticateAndSwipeUser';
+ constructor(
+ public con: ConnectorService,
+ public authService: AuthenticationService
+ ) {}
+ public attendanceSwipeScanner(attendanceSwipeScanner: attendanceSwipeScannerRequest, onError?: any, errorLabel?: string): Observable {
+ const request = attendanceSwipeScanner;
+ this.authService.authenticateRequest(request);
+ return this.con.post(this.AttendanceSwipeURL,request,onError,errorLabel);
+ }
+}
\ No newline at end of file