import { Component, OnInit } from '@angular/core'; import {PayslipService} from '../service/payslip.service' import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; import { CommonService } from 'src/app/hmg-common/services/common/common.service'; import { MenuResponse } from 'src/app/hmg-common/services/menu/models/menu-response'; import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service'; @Component({ selector: 'app-home', templateUrl: './home.component.html', styleUrls: ['./home.component.scss'], }) export class HomeComponent implements OnInit { selEmp: string; respID: number; selMenu: MenuResponse; GetPayslipList:any=''; GetSummaryOfPaymentList:any=''; GetPaymentInformationList:any=''; showPaySlip:any=[]; ActionContextID:any; public static ACTION_CONTEXT_ID = "passActionContectID"; constructor( public payslipService:PayslipService, public ts: TranslatorService, public common: CommonService, public sharedData: SharedDataService, ) {} ngOnInit() { console.log("test"); this.selEmp = this.common.sharedService.getSharedData( MenuResponse.SHARED_SEL_EMP, false ); console.log(" this.selEmp" + this.selEmp); this.respID = this.common.sharedService.getSharedData( MenuResponse.SHARED_SEL_RESP_ID, false ); console.log(" this.respID" + this.respID); this.selMenu = new MenuResponse(); this.selMenu = this.common.sharedService.getSharedData( MenuResponse.SHARED_DATA, false ); console.log(" this.selMenu" + this.selMenu); this.getPayslip(); } getPayslip(){ const request = { P_SELECTED_EMPLOYEE_NUMBER: this.selEmp,//'125346',//this.selEmp, P_MENU_TYPE: this.selMenu.List_Menu.MENU_TYPE,// 'E',//this.selMenu.List_Menu.MENU_TYPE, P_SELECTED_RESP_ID:this.respID//"-999" //this.respID, // P_PAGE_NUM: this.P_PAGE_NUM, // P_PAGE_LIMIT: this.P_PAGE_LIMIT }; this.payslipService.getPayslip(request, ()=> {} , this.ts.trPK('general', 'retry')).subscribe((result)=> { this.handleRespondGetPayslipResult(result); } ); } handleRespondGetPayslipResult(result){ if (result.GetPayslipList != null) { this.GetPayslipList = result.GetPayslipList; } } // showPaymentInfo showInfo(event){ console.log(event.detail.value); const index = parseInt(event.detail.value); this.showPaySlip =this.GetPayslipList[index]; this.ActionContextID=this.GetPayslipList[index].ACTION_CONTEXT_ID; this.common.sharedService.setSharedData(this.ActionContextID,HomeComponent.ACTION_CONTEXT_ID); this.getSummeryOfPayment(this.ActionContextID); this.getPaymentInfo(this.ActionContextID) } getSummeryOfPayment(ActionContextID){ const request = { P_ACTION_CONTEXT_ID: ActionContextID, }; this.payslipService.getSummeryOFPayment(request, ()=> {} , this.ts.trPK('general', 'retry')).subscribe((result)=> { this.handleSummeryOfPaymentResult(result); } ); } handleSummeryOfPaymentResult(result){ if (result.GetSummaryOfPaymentList != null) { this.GetSummaryOfPaymentList = result.GetSummaryOfPaymentList[0]; } } getPaymentInfo(ActionContextID){ const request = { P_ACTION_CONTEXT_ID: ActionContextID, }; this.payslipService.getPaymentInfo(request, ()=> {} , this.ts.trPK('general', 'retry')).subscribe((result)=> { this.handleGetPaymentInfoResult(result); } ); } handleGetPaymentInfoResult(result){ if (result.GetPaymentInformationList != null) { this.GetPaymentInformationList = result.GetPaymentInformationList[0]; } } openEarings(){ this.common.openEarningsPage(); } openDeductions(){ this.common.openDeductionsPage(); } }