|
|
|
|
@ -6,12 +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 { 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';
|
|
|
|
|
import { AttendanceService } from "./services/attendance.services";
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: "app-home",
|
|
|
|
|
@ -22,10 +22,10 @@ export class HomePage implements OnInit {
|
|
|
|
|
userData: any = {};
|
|
|
|
|
user_image: any = "../assets/imgs/profile.png";
|
|
|
|
|
menuList: any = [];
|
|
|
|
|
zbarOptions:any;
|
|
|
|
|
scannedResult:any;
|
|
|
|
|
lat : any;
|
|
|
|
|
longt : any;
|
|
|
|
|
zbarOptions: any;
|
|
|
|
|
scannedResult: any;
|
|
|
|
|
lat: any;
|
|
|
|
|
longt: any;
|
|
|
|
|
deviceID: string;
|
|
|
|
|
constructor(
|
|
|
|
|
public ts: TranslatorService,
|
|
|
|
|
@ -36,33 +36,38 @@ export class HomePage implements OnInit {
|
|
|
|
|
public events: Events,
|
|
|
|
|
private device: Device,
|
|
|
|
|
private zbar: ZBar,
|
|
|
|
|
private geolocation: Geolocation,
|
|
|
|
|
private attendance_service:AttendanceService
|
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
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();
|
|
|
|
|
@ -116,55 +121,59 @@ export class HomePage implements OnInit {
|
|
|
|
|
//this.getMenuEntries(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private Change_password(){
|
|
|
|
|
private Change_password() {
|
|
|
|
|
this.common.openChangePassword();
|
|
|
|
|
}
|
|
|
|
|
private attendance(){
|
|
|
|
|
private attendance() {
|
|
|
|
|
this.zbarOptions = {
|
|
|
|
|
flash: 'off',
|
|
|
|
|
flash: "off",
|
|
|
|
|
drawSight: false
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
console.log("your currnt location is");
|
|
|
|
|
|
|
|
|
|
this.scanCode();
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
});
|
|
|
|
|
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(){
|
|
|
|
|
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;
|
|
|
|
|
request.UserName = this.userData.EMPLOYEE_NUMBER;
|
|
|
|
|
console.log("request");
|
|
|
|
|
console.log(JSON.stringify(request));
|
|
|
|
|
this.attendance_service.attendanceSwipeScanner(
|
|
|
|
|
request,()=>{
|
|
|
|
|
this.attendance_service
|
|
|
|
|
.attendanceSwipeScanner(request, () => {
|
|
|
|
|
console.log("Error inside in swipe attendance");
|
|
|
|
|
}).
|
|
|
|
|
subscribe((result: Response) => {
|
|
|
|
|
})
|
|
|
|
|
.subscribe((result: Response) => {
|
|
|
|
|
if (this.common.validResponse(result)) {
|
|
|
|
|
console.log("response");
|
|
|
|
|
console.log(result);
|
|
|
|
|
this.common.presentAlert(this.ts.trPK('home', 'swipeAlertSuccess'));
|
|
|
|
|
this.common.presentAlert(this.ts.trPK("home", "swipeAlertSuccess"));
|
|
|
|
|
} else {
|
|
|
|
|
this.common.presentAlert(this.ts.trPK('home', 'swipeAlertFailed'));
|
|
|
|
|
this.common.presentAlert(this.ts.trPK("home", "swipeAlertFailed"));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
openPersonalInfo() {
|
|
|
|
|
this.common.openProfile();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|