@ -8,7 +8,6 @@ import { MenuService } from 'src/app/hmg-common/services/menu/menuservice.servic
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 { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx' ;
import { Device } from '@ionic-native/device/ngx' ;
import { attendanceSwipeScannerRequest } from './models/attendanceSwipe.Request' ;
@ -33,8 +32,6 @@ import { GetOpenNotificationsResponse } from '../hmg-common/services/dashbored/m
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' ;
import { TimeCardService } from '../time-card/service/time-card.service' ;
import { WorklistMainService } from '../notification/service/work-list.main.service' ;
@ -57,12 +54,12 @@ export class HomePage implements OnInit {
public fileUploder : FileUploaderComponent ;
location : boolean ;
camera : boolean ;
ticketRequestObject : any ;
leaveRequestObject : any ;
missingSwipeRequestObject : any ;
ticketRequestObject : any ;
leaveRequestObject : any ;
missingSwipeRequestObject : any ;
public statsButtons = [
{
title : 'Work List' ,
title : this.ts.trPK ( 'home' , 'worklist' ) ,
statsValue : 0 ,
icon : 'assets/icon/new-design/work_list.png' ,
link : '1'
@ -74,44 +71,25 @@ export class HomePage implements OnInit {
// link: ''
// },
{
title : 'Missing Swipes' ,
title : this.ts.trPK ( 'home' , 'missing-swipes' ) ,
statsValue : 0 ,
icon : 'assets/icon/new-design/missing_swipe.png' ,
link : '2'
} ,
{
title : 'Leave Balance' ,
title : this.ts.trPK ( 'home' , 'leave-balance' ) ,
statsValue : 0 ,
icon : 'assets/icon/new-design/leave_balance.png' ,
link : '3'
} ,
{
title : 'Ticket Balance' ,
title : this.ts.trPK ( 'absenceList' , 'tickets-balance' ) ,
statsValue : 0 ,
icon : 'assets/icon/new-design/ticket_balance.png' ,
link : '4'
}
] ;
// public employeeServicesButtons = [
// {
// title: 'Leave Management',
// icon: 'assets/icon/new-design/leave_management.png'
// },
// {
// title: 'Advance Payments',
// icon: 'assets/icon/new-design/advance_payments.png'
// },
// {
// title: 'Medical Insurance',
// icon: 'assets/icon/new-design/medical_insurance.png'
// },
// {
// title: 'Pay Slip',
// icon: 'assets/icon/new-design/pay_slip.png'
// }
// ];
public slideOptsOne = {
slidesPerView : 3.5 ,
spaceBetween : 10
@ -136,6 +114,12 @@ export class HomePage implements OnInit {
public menuType : any ;
accrualBalancesList : any ;
public countAllNotification = 0 ;
myTeamTitle : string ;
vacationRuleTitle : string ;
public myTeamIcon : string ;
public vacationRuleIcon : string ;
direction : string ;
public isPostNoLoad = true ;
constructor (
public ts : TranslatorService ,
@ -145,35 +129,40 @@ export class HomePage implements OnInit {
public common : CommonService ,
public events : Events ,
private device : Device ,
private zbar : ZBar ,
private geolocation : Geolocation ,
private attendanceService : AttendanceService ,
private eitService : EitService ,
private barcodeScanner : BarcodeScanner ,
public actionSheetCtrl : ActionSheetController ,
private cameraController : Camera ,
public sharedData : SharedDataService ,
private sanitizer : DomSanitizer ,
private file : File ,
private permissions : DevicePermissionsService ,
public DS : DashboredService ,
public accrualService : AccrualService ,
//////////////////////////////////////// TIME AND DATE////////////////////////////
public timeCardService : TimeCardService ,
///////////////////// END/////////////////////////////////////////////////////////
public workListService : WorklistMainService
) {
this . events . subscribe ( 'img-change' , displayImg = > {
this . userImage = this . sanitizer . bypassSecurityTrustUrl (
'data:Image/*;base64,' + displayImg
) ;
console . log ( 'html saved img: ' + this . userImage ) ;
} ) ;
}
ngOnInit() {
this . menu . enable ( true )
this . direction = TranslatorService . getCurrentLanguageName ( ) ;
// this.getUserDetails();
// this.getCount();
// this.events.subscribe('getNotCount', badge => {
// this.notBadge = badge;
// });
this . myTeamTitle = this . ts . trPK ( 'myTeam' , 'myTeam-header' ) ;
this . vacationRuleTitle = this . ts . trPK ( 'vacation-rule' , 'vacationRule' ) ;
// this.myTeamIcon="assets/icon/new-design/leave_balance.png";
// this.vacationRuleIcon="assets/icon/new-design/vacation_rules_icon.png"
this . common . startLoading ( ) ;
this . menu . enable ( true ) ;
// this.getUserDetails();
// this.getCount();
this . events . subscribe ( 'getNotCount' , badge = > {
@ -182,6 +171,7 @@ export class HomePage implements OnInit {
}
ionViewWillEnter() {
this . common . startLoading ( ) ;
this . remainingTime = 0 ;
this . displayTime = '00:00:00' ;
this . runTimer = false ;
@ -320,9 +310,9 @@ export class HomePage implements OnInit {
this . userData ,
AuthenticatedUser . SHARED_DATA
) ;
if ( this . common . getUpdateImage ( ) . status ) {
this . userImage = this . sanitizer . bypassSecurityTrustUrl ( "data:image/png;base64," + this . common . getUpdateImage ( ) . img ) ;
} else {
if ( this . common . getUpdateImage ( ) . status ) {
this . userImage = this . sanitizer . bypassSecurityTrustUrl ( 'data:image/png;base64,' + this . common . getUpdateImage ( ) . img ) ;
} else {
this . userImage = user . EMPLOYEE_IMAGE
? 'data:image/png;base64,' + user . EMPLOYEE_IMAGE
: this . userImage ;
@ -341,6 +331,7 @@ export class HomePage implements OnInit {
this . showOpenMissingSwipes ( ) ;
this . showAttendanceTracking ( ) ;
this . getAccrualBalance ( ) ;
// this.common.stopLoading();
}
public Vacation_Rule() {
@ -348,7 +339,7 @@ export class HomePage implements OnInit {
}
private getMenu() {
this . menuService . getMenu ( ) . subscribe ( ( result : MenuResponse ) = > {
this . menuService . getMenu ( '' , '' , this . isPostNoLoad ) . subscribe ( ( result : MenuResponse ) = > {
this . handleMenuResult ( result ) ;
} ) ;
}
@ -356,7 +347,6 @@ export class HomePage implements OnInit {
private handleMenuResult ( result ) {
if ( this . common . validResponse ( result ) ) {
if ( this . common . hasData ( result . List_Menu ) ) {
console . log ( 'list menu' ) ;
this . menuList = result . List_Menu ;
this . getMenuDetails ( ) ;
}
@ -376,15 +366,15 @@ export class HomePage implements OnInit {
const selMenu : MenuResponse = new MenuResponse ( ) ;
selMenu . List_Menu = item ;
selMenu . userid = this . userData . EMPLOYEE_NUMBER ;
console . log ( "menu: " + selMenu . List_Menu ) ;
this . common . sharedService . setSharedData ( selMenu , MenuResponse . SHARED_DATA ) ;
this . getMenuEntries ( item ) ;
for ( let i = 0 ; i < this.menuList.length ; i + + ) {
if ( this . menuList [ i ] . MENU_TYPE == "M" ) {
this . events . publish ( "myTeamFlag" , "true" ) ;
// tslint:disable-next-line: prefer-for-of
for ( let i = 0 ; i < this . menuList . length ; i ++ ) {
if ( this . menuList [ i ] . MENU_TYPE === 'M' ) {
this . events . publish ( 'myTeamFlag' , 'true' ) ;
}
}
// if (item.MENU_TYPE === 'M') {
// this.common.openMyTeamPage();
// // this.navCtrl.push("MySubordinatePage");
@ -426,7 +416,6 @@ export class HomePage implements OnInit {
request . P_MENU_TYPE = item . MENU_TYPE ;
request . NationalityCode = nationality ;
// set emp and resp id
console . log ( "set data" ) ;
this . common . sharedService . setSharedData (
selEmpNo ,
MenuResponse . SHARED_SEL_EMP
@ -437,7 +426,7 @@ export class HomePage implements OnInit {
) ;
this . eitService
. getMenuEntries ( request )
. getMenuEntries ( request , '' , '' , this . isPostNoLoad )
. subscribe ( ( result : MenuResponse ) = > {
this . handleMenuEntiresResult ( result ) ;
} ) ;
@ -446,9 +435,8 @@ export class HomePage implements OnInit {
sortMenuEntires ( list ) {
const tree = this . common . list_to_tree ( list ) ;
this . menuEntries = tree ;
console . log ( this . menuEntries ) ;
this . common . sharedService . setSharedData ( tree , "menuEntries" ) ;
this . common . sharedService . setSharedData ( "home" , "homemenuentries" ) ;
this . common . sharedService . setSharedData ( tree , 'menuEntries' ) ;
this . common . sharedService . setSharedData ( 'home' , 'homemenuentries' ) ;
// this.common.navigateForward("/eit/homepage");
// this.common.openEITPage();
}
@ -456,24 +444,26 @@ export class HomePage implements OnInit {
private handleMenuEntiresResult ( result ) {
if ( this . common . validResponse ( result ) ) {
if ( this . common . hasData ( result . GetMenuEntriesList ) ) {
for ( let i = 0 ; i < result.GetMenuEntriesList.length ; i + + ) {
if ( result . GetMenuEntriesList [ i ] . FUNCTION_NAME == "HMG_TKT_NEW_EIT_SS" ) {
this . ticketRequestObject = result . GetMenuEntriesList [ i ] ;
} else if ( result . GetMenuEntriesList [ i ] . FUNCTION_NAME == "HR_LOA_SS" ) {
this . leaveRequestObject = result . GetMenuEntriesList [ i ] ;
} else if ( result . GetMenuEntriesList [ i ] . FUNCTION_NAME == "HMG_OTL_MISSING_SWIPE_EIT_SS" ) {
this . missingSwipeRequestObject = result . GetMenuEntriesList [ i ] ;
// tslint:disable-next-line: prefer-for-of
for ( let i = 0 ; i < result . GetMenuEntriesList . length ; i ++ ) {
// tslint:disable-next-line: triple-equals
if ( result . GetMenuEntriesList [ i ] . FUNCTION_NAME == 'HMG_TKT_NEW_EIT_SS' ) {
this . ticketRequestObject = result . GetMenuEntriesList [ i ] ;
// tslint:disable-next-line: triple-equals
} else if ( result . GetMenuEntriesList [ i ] . FUNCTION_NAME == 'HR_LOA_SS' ) {
this . leaveRequestObject = result . GetMenuEntriesList [ i ] ;
// tslint:disable-next-line: triple-equals
} else if ( result . GetMenuEntriesList [ i ] . FUNCTION_NAME == 'HMG_OTL_MISSING_SWIPE_EIT_SS' ) {
this . missingSwipeRequestObject = result . GetMenuEntriesList [ i ] ;
}
}
}
this . sortMenuEntires ( result . GetMenuEntriesList ) ;
}
}
}
parentFn ( $event : string ) {
console . log ( $event ) ; // this will output 'hello from child'
console . log ( $event ) ;
}
private Change_password() {
@ -502,7 +492,7 @@ export class HomePage implements OnInit {
this . swipeAttendance ( ) ;
} )
. catch ( err = > {
console . log ( "Error" , err ) ;
console . log ( 'Error' , err ) ;
} ) ;
}
@ -513,14 +503,13 @@ export class HomePage implements OnInit {
request . QRValue = this . scannedResult . text ;
request . UID = this . deviceID ;
request . UserName = this . userData . EMPLOYEE_NUMBER ;
console . log ( JSON . stringify ( request ) ) ;
this . attendanceService
. attendanceSwipeScanner ( request , ( ) = > {
console . log ( "Error inside in swipe attendance" ) ;
console . log ( 'Error inside in swipe attendance' ) ;
} )
. subscribe ( ( result : Response ) = > {
if ( this . common . validResponse ( result ) ) {
this . common . presentAlert ( this . ts . trPK ( "home" , "swipeAlertSuccess" ) ) ;
this . common . presentAlert ( this . ts . trPK ( 'home' , 'swipeAlertSuccess' ) ) ;
this . showAttendanceTracking ( ) ;
}
// else {
@ -533,8 +522,7 @@ export class HomePage implements OnInit {
this . common . openProfile ( ) ;
}
/*************************************Dashboards Services**********************************************************8 */
// Dashboard Services
showOrganizationSalaries() {
this . DS . getOrganizationSalaries ( ) . subscribe (
( result : OrganizationSalariesResponse ) = > { }
@ -542,10 +530,10 @@ export class HomePage implements OnInit {
}
showOpenMissingSwipes() {
this . DS . getOpenMissingSwipes ( ) . subscribe (
this . DS . getOpenMissingSwipes ( '' , '' , this . isPostNoLoad ) . subscribe (
( result : OpenMissingSwipesResponse ) = > {
if ( this . common . validResponse ( result ) ) {
const key = "GetOpenMissingSwipesList" ;
const key = 'GetOpenMissingSwipesList' ;
this . statsButtons [ 1 ] . statsValue = Math . floor ( result [ key ] . P_OPEN_MISSING_SWIPES ) ;
}
}
@ -567,7 +555,6 @@ export class HomePage implements OnInit {
}
convertAndAssignTime ( data ) {
console . log ( data ) ;
this . remainingTime = this . convertInSeconds ( data . P_REMAINING_HOURS . split ( ':' ) ) ;
this . scheduledTime = this . convertInSeconds ( data . P_SCHEDULED_HOURS . split ( ':' ) ) ;
this . spentHours = this . convertInSeconds ( data . P_SPENT_HOURS . split ( ':' ) ) ;
@ -581,7 +568,7 @@ showAttendanceTracking() {
const request = {
P_SELECTED_EMPLOYEE_NUMBER : this.userData.EMPLOYEE_NUMBER
} ;
this . DS . getAttendanceTracking ( request ). subscribe ( ( result : AttendanceTrackingResponse ) = > {
this . DS . getAttendanceTracking ( request , '' , '' , this . isPostNoLoad ). subscribe ( ( result : AttendanceTrackingResponse ) = > {
if ( this . common . validResponse ( result ) ) {
const key = 'GetAttendanceTrackingList' ;
this . convertAndAssignTime ( result [ key ] ) ;
@ -598,10 +585,7 @@ openPeriodDateDashbored() {
}
openNotificationsDashbored() {
// work list
this . DS . getOpenNotifications ( ( ) = > {
console . log ( "Error " ) ;
} ) . subscribe ( ( result : GetOpenNotificationsResponse ) = > {
this . DS . getOpenNotifications ( '' , '' , this . isPostNoLoad ) . subscribe ( ( result : GetOpenNotificationsResponse ) = > {
if ( this . common . validResponse ( result ) ) {
const key = 'P_OPEN_NTF_NUMBER' ;
this . countAllNotification = result [ key ] ;
@ -615,18 +599,19 @@ openPeriodDateDashbored() {
}
ITGCountAllNotification() {
this . workListService . getITGDetails ( ) . subscribe ( ( result : any ) = > {
this . workListService . getITGDetails ( '' , '' , this . isPostNoLoad ) . subscribe ( ( result : any ) = > {
this . statsButtons [ 0 ] . statsValue =
Math . floor ( this . countAllNotification + result . TotalCount ) ;
this . common . stopLoading ( ) ;
} ) ;
}
getSubordinatesLeaves() {
const request : GetSubordinatesLeavesRequest = new GetSubordinatesLeavesRequest ( ) ;
request . P_DATE_FROM = "/Date(1578603600000+0300)/" ; // test
request . P_DATE_TO = "/Date(1576011600000+0300)/" ; // test
request . P_DATE_FROM = '/Date(1578603600000+0300)/' ; // test
request . P_DATE_TO = '/Date(1576011600000+0300)/' ; // test
this . DS . getSubordinatesLeaves ( request , ( ) = > {
console . log ( "Error " ) ;
console . log ( 'Error ' ) ;
} ) . subscribe ( ( result : GetSubordinatesLeavesResponse ) = > {
if ( this . common . validResponse ( result ) ) {
console . log ( 'response' ) ;
@ -637,10 +622,10 @@ openPeriodDateDashbored() {
getSubordinatesAttStatus() {
const request : GetSubordinatesAttdStatusRequest = new GetSubordinatesAttdStatusRequest ( ) ;
request . P_SCHEDULE_DATE_FROM = "/Date(1578603600000+0300)/" ; // test
request . P_SCHEDULE_DATE_TO = "/Date(1576011600000+0300)/" ; // test
request . P_SCHEDULE_DATE_FROM = '/Date(1578603600000+0300)/' ; // test
request . P_SCHEDULE_DATE_TO = '/Date(1576011600000+0300)/' ; // test
this . DS . getSubordinatesAttStatus ( request , ( ) = > {
console . log ( "Error " ) ;
console . log ( 'Error ' ) ;
} ) . subscribe ( ( result : GetSubordinatesAttdStatusResponse ) = > {
if ( this . common . validResponse ( result ) ) {
console . log ( 'response' ) ;
@ -650,7 +635,7 @@ getSubordinatesAttStatus() {
}
openPage ( subMenu ) {
console . log ( "openPage" ) ;
console . log ( subMenu ) ;
let selMenu : MenuResponse = new MenuResponse ( ) ;
selMenu = this . common . sharedService . getSharedData (
MenuResponse . SHARED_DATA ,
@ -681,41 +666,28 @@ getSubordinatesAttStatus() {
const day = today . getDate ( ) ;
const month = today . getMonth ( ) + 1 ;
const year = today . getFullYear ( ) ;
const todayDate = month + "/" + day + "/" + year ;
const todayDate = month + '/' + day + '/' + year ;
const effectiveDate = todayDate ;
const request = {
P_SELECTED_EMPLOYEE_NUMBER : this.userData.EMPLOYEE_NUMBER ,
P_EFFECTIVE_DATE : effectiveDate
} ;
this . accrualService . getAccrualBalances ( request ). subscribe ( ( result : any ) = > {
this . accrualService . getAccrualBalances ( request , '' , '' , this . isPostNoLoad ). subscribe ( ( result : any ) = > {
if ( this . common . validResponse ( result ) ) {
let totalTicketsLeft = 0 ;
this . accrualBalancesList = result . GetAccrualBalancesList ;
for ( const accrualBalance of result . GetAccrualBalancesList ) {
if (
accrualBalance . ACCURAL_PLAN_NAME ===
"HMG Annual Vacation Accrual Plan"
) {
if ( accrualBalance . ACCURAL_PLAN_NAME === 'HMG Annual Vacation Accrual Plan' ) {
this . statsButtons [ 2 ] . statsValue =
Math . floor ( accrualBalance . ACCRUAL_NET_ENTITLEMENT ) ;
this . common . sharedService . setSharedData (
accrualBalance ,
"leaveAccrualBalance"
) ;
this . common . sharedService . setSharedData (
request ,
"leaveAccrualBalanceDate"
) ;
this . common . sharedService . setSharedData (
this . accrualBalancesList ,
"tickitsbalance"
) ;
this . common . sharedService . setSharedData ( accrualBalance , 'leaveAccrualBalance' ) ;
this . common . sharedService . setSharedData ( request , 'leaveAccrualBalanceDate' ) ;
this . common . sharedService . setSharedData ( this . accrualBalancesList , 'tickitsbalance' ) ;
} else {
totalTicketsLeft =
totalTicketsLeft + accrualBalance . ACCRUAL_NET_ENTITLEMENT ;
totalTicketsLeft = totalTicketsLeft + accrualBalance . ACCRUAL_NET_ENTITLEMENT ;
}
}
this . statsButtons [ 3 ] . statsValue = Math . floor ( totalTicketsLeft ) ;
this . statsButtons [ 3 ] . statsValue = Math . floor ( totalTicketsLeft ) ;
}
} ) ;
}
@ -730,14 +702,18 @@ openProfilePage() {
openStatsButton ( link : any ) {
// console.log(link);
if ( link == "1" ) {
// tslint:disable-next-line: triple-equals
if ( link == '1' ) {
this . common . startLoading ( ) ;
this . common . openNotificationPage ( ) ;
} else if ( link == "2" ) {
// tslint:disable-next-line: triple-equals
} else if ( link == '2' ) {
this . openPage ( this . missingSwipeRequestObject ) ;
} else if ( link == "3" ) {
// tslint:disable-next-line: triple-equals
} else if ( link == '3' ) {
this . openPage ( this . leaveRequestObject ) ;
} else if ( link == "4" ) {
// tslint:disable-next-line: triple-equals
} else if ( link == '4' ) {
this . openPage ( this . ticketRequestObject ) ;
}
}