diff --git a/Mohem/src/app/absence/home/home.component.ts b/Mohem/src/app/absence/home/home.component.ts index 131f5127..1e08083c 100644 --- a/Mohem/src/app/absence/home/home.component.ts +++ b/Mohem/src/app/absence/home/home.component.ts @@ -37,17 +37,18 @@ export class HomeComponent implements OnInit { balance: any; ACCRUAL_NET_ENTITLEMENT: any; ACCRUAL_USED_ENTITLEMENT: any; - ACCRUAL_YEARLY_ENTITLEMENT: any; - totalnumber: any; - public direction: string; - + ACCRUAL_YEARLY_ENTITLEMENT: any; + totalnumber: any; + public direction: string; + public options = { cutoutPercentage: 80, tooltips: { enabled: false }, - legend: { display: false }}; - gaugeType = "full"; - // gaugeValue = 11.200; - // gaugeLabel = ""; + legend: { display: false } + }; + gaugeType = "full"; + // gaugeValue = 11.200; + // gaugeLabel = ""; constructor( public common: CommonService, @@ -58,23 +59,23 @@ export class HomeComponent implements OnInit { public authService: AuthenticationService ) { this.direction = TranslatorService.getCurrentDirection(); - // this.userData =this.common.sharedService.getSharedData(AuthenticatedUser.SHARED_DATA,false); + // this.userData =this.common.sharedService.getSharedData(AuthenticatedUser.SHARED_DATA,false); } ngOnInit() { this.Sdate = new Date().toISOString(); - + this.getUserDetails(); this.getAccrualBalance(); } - private getUserDetails(){ + private getUserDetails() { this.authService.loadAuthenticatedUser().subscribe((user: AuthenticatedUser) => { - if (user) { - // this.emp_no=user.EMPLOYEE_NUMBER; - // this.getAccrualBalance(); - } - }); + if (user) { + // this.emp_no=user.EMPLOYEE_NUMBER; + // this.getAccrualBalance(); + } + }); @@ -102,36 +103,36 @@ export class HomeComponent implements OnInit { this.accrualNet = this.leaveAccrualBalance.ACCRUAL_NET_ENTITLEMENT; this.accrualUsed = this.leaveAccrualBalance.ACCRUAL_USED_ENTITLEMENT; this.accrualYearly = this.leaveAccrualBalance.ACCRUAL_YEARLY_ENTITLEMENT; - this.totalnumber= this.accrualNet + this.accrualUsed + this.accrualYearly; - this.totalnumber= this.totalnumber.toFixed(3); + this.totalnumber = this.accrualNet + this.accrualUsed + this.accrualYearly; + this.totalnumber = this.totalnumber.toFixed(3); this.request = this.common.sharedService.getSharedData('leaveAccrualBalanceDate', false); console.log("this.request" + this.request.P_EFFECTIVE_DATE); this.effectiveDate = this.request.P_EFFECTIVE_DATE; this.data = { // labels: ['earingTotal', 'deductionTotal'], datasets: [ - // { data: [this.accrualNet,this.accrualYearly,this.accrualUsed], - { - data: [this.accrualNet,this.accrualUsed], - backgroundColor: [ - // '#1FA269', - // '#CB3232',], - '#269DB8', - '#b60c0c',], - borderWidth: 1 - } - ] - }; + // { data: [this.accrualNet,this.accrualYearly,this.accrualUsed], + { + data: [this.accrualNet, this.accrualUsed], + backgroundColor: [ + // '#1FA269', + // '#CB3232',], + '#269DB8', + '#b60c0c',], + borderWidth: 1 + } + ] + }; this.getAbsenceTransaction(); } -AccrualBalances() { + AccrualBalances() { this.common.openAccuralPage(); } -AttachmentDocuments(id) { + AttachmentDocuments(id) { const request = { P_ABSENCE_ATTENDANCE_ID: id }; @@ -159,7 +160,7 @@ AttachmentDocuments(id) { //this.GetAbsenceTransactionList =result.GetAbsenceTransactionList; } } -getAbsenceTransaction() { + getAbsenceTransaction() { this.IsReachEnd = false; const request = { P_SELECTED_EMPLOYEE_NUMBER: this.selEmp, @@ -173,7 +174,7 @@ getAbsenceTransaction() { }); } - handleAbsListResult(result) { + handleAbsListResult(result) { if (this.common.validResponse(result)) { if (this.common.hasData(result.GetAbsenceTransactionList)) { this.GetAbsenceTransactionList = result.GetAbsenceTransactionList; @@ -190,7 +191,7 @@ getAbsenceTransaction() { } } } -doInfinite(event: any) { + doInfinite(event: any) { if (!this.IsReachEnd) { // this.P_PAGE_NUM++; const request = { @@ -230,11 +231,11 @@ doInfinite(event: any) { } } } -createAbsence() { + createAbsence() { this.common.openSubmitAbsencePage(); } -/////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////// getAccrualBalance() { if (this.Sdate) { let today = new Date(this.Sdate); @@ -255,31 +256,32 @@ createAbsence() { }); } } - + handleAccrualResult(result) { if (this.common.validResponse(result)) { this.balance = result.GetAccrualBalancesList; - } - if(this.balance){ - this.accrualNet = this.balance[0].ACCRUAL_NET_ENTITLEMENT; - this.accrualUsed = this.balance[0].ACCRUAL_USED_ENTITLEMENT; - // this.accrualYearly = this.balance[0].ACCRUAL_YEARLY_ENTITLEMENT; - // this.totalnumber= this.accrualNet + this.accrualUsed + this.accrualYearly; - this.totalnumber= this.accrualNet + this.accrualUsed; - this.totalnumber= this.totalnumber.toFixed(3); - this.data = { - // labels: ['earingTotal', 'deductionTotal'], - datasets: [ - // { data: [this.accrualNet,this.accrualYearly,this.accrualUsed], - { data: [this.accrualNet,this.accrualUsed], - backgroundColor: [ - '#269DB8', - '#b60c0c',], - borderWidth: 1 - } - ] - }; + } + if (this.balance) { + this.accrualNet = this.balance[0].ACCRUAL_NET_ENTITLEMENT; + this.accrualUsed = this.balance[0].ACCRUAL_USED_ENTITLEMENT; + // this.accrualYearly = this.balance[0].ACCRUAL_YEARLY_ENTITLEMENT; + // this.totalnumber= this.accrualNet + this.accrualUsed + this.accrualYearly; + this.totalnumber = this.accrualNet + this.accrualUsed; + this.totalnumber = this.totalnumber.toFixed(3); + this.data = { + // labels: ['earingTotal', 'deductionTotal'], + datasets: [ + // { data: [this.accrualNet,this.accrualYearly,this.accrualUsed], + { + data: [this.accrualNet, this.accrualUsed], + backgroundColor: [ + '#269DB8', + '#b60c0c',], + borderWidth: 1 + } + ] + }; - } + } } } diff --git a/Mohem/src/app/app.component.ts b/Mohem/src/app/app.component.ts index 3f24ffbf..40b54e26 100644 --- a/Mohem/src/app/app.component.ts +++ b/Mohem/src/app/app.component.ts @@ -9,9 +9,10 @@ import { PushService } from '../../src/app/hmg-common/services/push/push.service import { LazyLoadingService } from './hmg-common/services/lazy-loading/lazy-loading.service'; import { DomSanitizer } from '@angular/platform-browser'; import { SplashScreen } from '@ionic-native/splash-screen/ngx'; -import { Router } from '@angular/router'; +import { Router, NavigationEnd } from '@angular/router'; import { DigitalIdComponent } from './authentication/digital-id/digital-id.component'; import { checkAndUpdatePureExpressionInline } from '@angular/core/src/view/pure_expression'; +import { FirebaseX } from '@ionic-native/firebase-x/ngx'; @Component({ selector: 'app-root', @@ -56,6 +57,7 @@ export class AppComponent implements OnInit { public router: Router, public modalController: ModalController, public nav: NavController, + public firebasex: FirebaseX ) { this.events.subscribe('img-change', displayImg => { console.log('app compont: ' + displayImg); @@ -83,6 +85,7 @@ export class AppComponent implements OnInit { this.ts.loadResources(() => { this.isIOS = this.platform.is('ios') ? true : false; this.initializeDirection(); + this.monitorAnalytics(); this.start = true; if (this.isIOS) { this.monitUrlChange(); @@ -105,6 +108,24 @@ export class AppComponent implements OnInit { }); } + public monitorAnalytics() { + this.router.events.subscribe((val) => { + if (val instanceof NavigationEnd) { + const lastIndex = val.urlAfterRedirects.lastIndexOf('/'); + const currentPageName = val.urlAfterRedirects.substr(lastIndex + 1); + this.setScreenNameAnalytics(currentPageName); + } + }); + } + + public setScreenNameAnalytics(currentPageName: string) { + try { + this.firebasex.setScreenName(currentPageName).then((result)=>{ + console.log(result); + }); + } catch (Error) { } + } + private startReceivingPushService() { this.pushService.startReceiving(); setTimeout(() => { diff --git a/Mohem/src/app/hmg-common/services/common/common.service.ts b/Mohem/src/app/hmg-common/services/common/common.service.ts index c62a99f8..cba9d334 100644 --- a/Mohem/src/app/hmg-common/services/common/common.service.ts +++ b/Mohem/src/app/hmg-common/services/common/common.service.ts @@ -1090,6 +1090,9 @@ export class CommonService { public openConfirmEitPage() { this.nav.navigateForward(['/eit/confirm-add-eit']); } + public openConfirmBasicDetailsPage() { + this.nav.navigateForward(['/profile/confirm-basic']); + } public openHome() { this.nav.navigateRoot(['/home']); } @@ -1116,8 +1119,13 @@ export class CommonService { public openEditProfile() { this.nav.navigateForward(['/profile/editprofile']); } - public openAddBasicDetails() { - this.nav.navigateForward(['/profile/addBasicDetails']); + public openAddBasicDetails(target: string) { + const navigationExtras: NavigationExtras = { + queryParams: { + targetValue: target + } + }; + this.nav.navigateForward(['/profile/addBasicDetails'], navigationExtras); } public openAccuralPage() { this.nav.navigateForward(['/accrual-balances/home']); diff --git a/Mohem/src/app/notification/work-list-main-itg/work-list-main-itg.component.ts b/Mohem/src/app/notification/work-list-main-itg/work-list-main-itg.component.ts index d257ff59..25da5c26 100644 --- a/Mohem/src/app/notification/work-list-main-itg/work-list-main-itg.component.ts +++ b/Mohem/src/app/notification/work-list-main-itg/work-list-main-itg.component.ts @@ -18,20 +18,22 @@ import { ApplyActionModalComponent } from '../apply-action-modal/apply-action-mo export class WorkListMainItgComponent implements OnInit { @ViewChild('slides') slides: IonSlides; - public static APPROVAL = "Services/COCWS.svc/REST/ITGApproveRequest" - public static REJECT = 'Services/COCWS.svc/REST/ITGRejectRequest' + // tslint:disable: member-ordering + public static APPROVAL = 'Services/COCWS.svc/REST/ITGApproveRequest'; + public static REJECT = 'Services/COCWS.svc/REST/ITGRejectRequest'; public static DELEGATE = 'Services/COCWS.svc/REST/ITGDelegateRequest'; public static REQUEST_INFORMATION = 'Services/COCWS.svc/REST/ITGRequestInformation'; public static ANSWER = 'Services/COCWS.svc/REST/ITGAnswer'; public static GRANT = 'Services/COCWS.svc/REST/ITGGrantAccess'; + // tslint:disable: variable-name public request_info: any; public request_name: any; public all_request: any; public all_request_names: any; public is_all_items_sents: any; public request = new itgRequest(); - public activeSegment: any = "info"; + public activeSegment: any = 'info'; public request_details: any; public segmentsArray: { name: string, number: number }[] = []; public segmentData: { name: string, data: any }[] = []; @@ -44,7 +46,7 @@ export class WorkListMainItgComponent implements OnInit { public replcamentID: string; public actionSelected: any; public options: any; - public index: number = 0; + public index = 0; public grantDATA: any; public grantInfo: any; public grantFieldsConditionalValue: any = []; @@ -67,7 +69,7 @@ export class WorkListMainItgComponent implements OnInit { public modalCtrl: ModalController) { } ngOnInit() { - this.direction = TranslatorService.getCurrentLanguageName() + this.direction = TranslatorService.getCurrentLanguageName(); this.request_info = this.common.sharedService.getSharedData(HomeComponent.REQUSET_INFO); this.request_name = this.common.sharedService.getSharedData(HomeComponent.REQUSET_NAME); this.all_request = this.common.sharedService.getSharedData(HomeComponent.ALL_REQUEST); @@ -90,19 +92,14 @@ export class WorkListMainItgComponent implements OnInit { this.workListService.getITGFormDetails(this.request).subscribe((result: any) => { this.request_details = result.ITGRequest; this.grantInfo = result.ITGRequest.GrantFields; - let count = 0; for (let i = 0; i < result.ITGRequest.FieldGoups.length; i++) { this.segmentsArray[i] = { name: result.ITGRequest.FieldGoups[i].Title, number: i }; - this.segmentData[i] = { name: result.ITGRequest.FieldGoups[i].Title, data: result.ITGRequest.FieldGoups[i].Fields } + this.segmentData[i] = { name: result.ITGRequest.FieldGoups[i].Title, data: result.ITGRequest.FieldGoups[i].Fields }; + // tslint:disable: prefer-for-of for (let j = 0; j < this.segmentData[i].data.length; j++) { - if (this.segmentData[i].data[j].Type === "table") { - this.dataLabelAndValue.push(JSON.parse(this.segmentData[i].data[j].Value)) + if (this.segmentData[i].data[j].Type === 'table') { + this.dataLabelAndValue.push(JSON.parse(this.segmentData[i].data[j].Value)); } - // if (this.segmentData[i].data[j].TableValue){ - // this.requestDetailsData[count] ={ name:this.segmentData[i].data[j].TableValue.Header, - // data: this.segmentData[i].data[j].TableValue.Rows} - // count++; - // } } } this.segmentsArray[this.segmentsArray.length] = { name: 'Approval Level', number: this.segmentsArray.length }; @@ -135,62 +132,56 @@ export class WorkListMainItgComponent implements OnInit { } } } - //result.ITGRequest.FieldGoups.Fields }); } imageURL(actionName) { - if (actionName == "Approve") { - return "../assets/imgs/mohemm-action/Approve.png" + if (actionName === 'Approve') { + return '../assets/imgs/mohemm-action/Approve.png'; } - if (actionName == "Reject") { - return "../assets/imgs/mohemm-action/Reject.png" + if (actionName === 'Reject') { + return '../assets/imgs/mohemm-action/Reject.png'; } - if (actionName == "RequestInformation") { - return "../assets/imgs/mohemm-action/info.png" + if (actionName === 'RequestInformation') { + return '../assets/imgs/mohemm-action/info.png'; } - if (actionName == "Grant") { - return "../assets/imgs/mohemm-action/info.png" + if (actionName === 'Grant') { + return '../assets/imgs/mohemm-action/info.png'; } - if (actionName == "Delegate") { - return "../assets/imgs/mohemm-action/info.png" + if (actionName === 'Delegate') { + return '../assets/imgs/mohemm-action/info.png'; } - if (actionName == "Answer") { - return "../assets/imgs/mohemm-action/info.png" + if (actionName === 'Answer') { + return '../assets/imgs/mohemm-action/info.png'; } - if (actionName == "ReportGenerated") { - return "../assets/imgs/mohemm-action/info.png" + if (actionName === 'Question') { + return '../assets/imgs/mohemm-action/info.png'; } - if (actionName == "Doable") { - return "../assets/imgs/mohemm-action/info.png" + if (actionName === 'ReportGenerated') { + return '../assets/imgs/mohemm-action/info.png'; } - if (actionName == "NotDoable") { - return "../assets/imgs/mohemm-action/info.png" + if (actionName === 'Doable') { + return '../assets/imgs/mohemm-action/info.png'; } - if (actionName == "DataCorrected") { - return "../assets/imgs/mohemm-action/info.png" + if (actionName === 'NotDoable') { + return '../assets/imgs/mohemm-action/info.png'; + } + if (actionName === 'DataCorrected') { + return '../assets/imgs/mohemm-action/info.png'; } } public segmentChangedClick(event: any) { - if (event.detail.value === "Request Details") { + if (event.detail.value === 'Request Details') { this.slides.slideTo(0); this.activeSegment = event.detail.value; - } - else if (event.detail.value === "Approval Level") { + } else if (event.detail.value === 'Approval Level') { this.slides.slideTo(1); this.activeSegment = event.detail.value; - } - else if (event.detail.value === "Requester Details") { + } else if (event.detail.value === 'Requester Details') { this.slides.slideTo(2); this.activeSegment = event.detail.value; } - // for(let i=0; i< this.segmentsArray.length; i++){ - // if(this.segmentsArray[i].name === event.detail.value){ - // this.slides.slideTo(i); - // this.activeSegment = event.detail.value; - // } - // } } slideChanged(event: any) { @@ -224,11 +215,9 @@ export class WorkListMainItgComponent implements OnInit { } } } - } - //if user clicked on spicific type of ITG request - else { + } else { // if user clicked on spicific type of ITG request for (let i = 0; i < this.all_request.length; i++) { // search for the request that clicked on all request - if (this.request_info.ID == this.all_request[i].ID) { // check if the ID for the request is found. + if (this.request_info.ID === this.all_request[i].ID) { // check if the ID for the request is found. this.index = i + 1; if (this.index !== this.all_request.length) { // check if its last one to redirecte to home otherwise to next request. this.clearDataArray(); @@ -240,11 +229,6 @@ export class WorkListMainItgComponent implements OnInit { return; } } - // else { - // this.common.sharedService.setSharedData(true, 'loadWorkList'); - // this.common.openNotificationPage(); - // return; - // } } } this.common.sharedService.setSharedData(true, 'loadWorkList'); @@ -266,7 +250,7 @@ export class WorkListMainItgComponent implements OnInit { actionService(action, comments?, grantRequests?) { let url: string; - let request = new itgRequest(); + const request = new itgRequest(); request.RequestType = this.request_name; request.ItemID = this.request_info.ItemID; request.TaskID = this.request_info.ID; @@ -276,14 +260,14 @@ export class WorkListMainItgComponent implements OnInit { request.NewUserEMPId = this.replcamentID; this.common.confirmAlertDialogAction( () => { - if (action == 1) { //approved + if (action === 1) { // approved url = WorkListMainItgComponent.APPROVAL; this.workListService.getITGActionRequest(request, url) .subscribe((result: any) => { - if (result.MessageStatus != 1) { + if (result.MessageStatus !== 1) { this.common.presentAlert(this.ts.trPK('general', 'error-itg')); - } else if (result.MessageStatus == 1) { + } else if (result.MessageStatus === 1) { this.messageSuccess = true; setTimeout(() => { this.messageSuccess = false; @@ -293,26 +277,24 @@ export class WorkListMainItgComponent implements OnInit { }, 2000); } }); - } else if (action == 2) {//reject + } else if (action === 2) {// reject url = WorkListMainItgComponent.REJECT; this.workListService.getITGActionRequest(request, url) .subscribe((result: any) => { - if (result.MessageStatus != 1) { + if (result.MessageStatus !== 1) { this.common.presentAlert(this.ts.trPK('general', 'error-itg')); - } else if (result.MessageStatus == 1) { + } else if (result.MessageStatus === 1) { setTimeout(() => { this.messageSuccess = true; this.common.sharedService.setSharedData(true, 'loadWorkList'); - // this.common.presentAlert(this.ts.trPK('worklistMain', 'Tran_Succ')); - // this.common.sharedService.setSharedData(true, 'loadWorkList'); this.confirmMsg(2); this.skip(); this.messageSuccess = false; }, 2000); } }); - } else if (action == 3) {//request more info + } else if (action === 3) {// request more info request.NewUserEMPId = this.replcamentID; url = WorkListMainItgComponent.REQUEST_INFORMATION; if (!comments) { @@ -321,12 +303,11 @@ export class WorkListMainItgComponent implements OnInit { request.Comments = comments; this.workListService.getITGActionRequest(request, url) .subscribe((result: any) => { - if (result.MessageStatus != 1) { - //this.common.presentAlert(result.Message); + if (result.MessageStatus !== 1) { this.common.presentAlert(this.ts.trPK('general', 'error-itg')); } - if (result.MessageStatus == 1) { + if (result.MessageStatus === 1) { this.messageSuccess = true; setTimeout(() => { this.messageSuccess = false; @@ -339,15 +320,15 @@ export class WorkListMainItgComponent implements OnInit { } }); } - } else if (action == 4) {//delegate + } else if (action === 4) {// delegate request.NewUserEMPId = this.replcamentID; url = WorkListMainItgComponent.DELEGATE; this.workListService.getITGActionRequest(request, url) .subscribe((result: any) => { - if (result.MessageStatus != 1) { + if (result.MessageStatus !== 1) { this.common.presentAlert(this.ts.trPK('general', 'error-itg')); - } else if (result.MessageStatus == 1) { + } else if (result.MessageStatus === 1) { this.messageSuccess = true; setTimeout(() => { this.messageSuccess = false; @@ -359,17 +340,17 @@ export class WorkListMainItgComponent implements OnInit { }, 2000); } }); - } else if (action == 5) { //answer + } else if (action === 5) { // answer url = WorkListMainItgComponent.ANSWER; if (!comments) { this.common.presentAlert(this.ts.trPK('worklist', 'empty-comment')); } else { this.workListService.getITGActionRequest(request, url) .subscribe((result: any) => { - if (result.MessageStatus != 1) { + if (result.MessageStatus !== 1) { this.common.presentAlert(this.ts.trPK('general', 'error-itg')); - } else if (result.MessageStatus == 1) { + } else if (result.MessageStatus === 1) { this.messageSuccess = true; setTimeout(() => { this.messageSuccess = false; @@ -382,20 +363,19 @@ export class WorkListMainItgComponent implements OnInit { } }); } - } else if (action == 6) { //grant + } else if (action === 6) { // grant url = WorkListMainItgComponent.GRANT; if (!comments) { this.common.presentAlert(this.ts.trPK('worklist', 'empty-comment')); - } - else { + } else { if (this.grantRequest) { request.AdditionalFields = this.grantRequest; this.workListService.getITGActionRequest(request, url) .subscribe((result: any) => { - if (result.MessageStatus != 1) { + if (result.MessageStatus !== 1) { this.common.presentAlert(this.ts.trPK('general', 'error-itg')); - } else if (result.MessageStatus == 1) { + } else if (result.MessageStatus === 1) { this.messageSuccess = true; setTimeout(() => { this.messageSuccess = false; @@ -412,16 +392,16 @@ export class WorkListMainItgComponent implements OnInit { } } - } else if (action == 7) { //grant + } else if (action === 7) { // grant url = WorkListMainItgComponent.GRANT; if (this.grantRequest) { request.AdditionalFields = this.grantRequest; this.workListService.getITGActionRequest(request, url) .subscribe((result: any) => { - if (result.MessageStatus != 1) { + if (result.MessageStatus !== 1) { this.common.presentAlert(this.ts.trPK('general', 'error-itg')); - } else if (result.MessageStatus == 1) { + } else if (result.MessageStatus === 1) { this.messageSuccess = true; setTimeout(() => { this.messageSuccess = false; @@ -476,13 +456,13 @@ export class WorkListMainItgComponent implements OnInit { selectAtion(actionSelected) { this.actionSelected = actionSelected; - if (this.actionSelected == "Answer") { - this.actionService(5, this.commentText) + if (this.actionSelected === 'Answer') { + this.actionService(5, this.commentText); } - if (this.actionSelected == "Approve") { + if (this.actionSelected === 'Approve') { this.actionService(1, this.commentText); } - if (this.actionSelected == "Delegate") { + if (this.actionSelected === 'Delegate') { this.presentModal(4); } if (this.actionSelected === 'Doable') { @@ -495,6 +475,7 @@ export class WorkListMainItgComponent implements OnInit { this.actionService(2, this.commentText); } if (this.actionSelected === 'Question') { + this.actionService(5, this.commentText); } if (this.actionSelected === 'Reject') { this.actionService(2, this.commentText); @@ -522,9 +503,9 @@ export class WorkListMainItgComponent implements OnInit { .then((data) => { this.replcamentID = data.data.empData.USER_NAME; this.commentText = data.data.comments; - if (actionNumber == 3) { + if (actionNumber === 3) { this.actionService(3, this.commentText); - } else if (actionNumber == 4) { + } else if (actionNumber === 4) { this.actionService(4); } diff --git a/Mohem/src/app/offersdiscount/home/home.component.html b/Mohem/src/app/offersdiscount/home/home.component.html index e0c1a3f6..1d41025c 100644 --- a/Mohem/src/app/offersdiscount/home/home.component.html +++ b/Mohem/src/app/offersdiscount/home/home.component.html @@ -1,24 +1,22 @@
- - - + + +
- +
- + - - - + + + @@ -29,60 +27,66 @@ - - -
-
-
-
- - -
-
-

{{key.categoryName_en}}

-

{{key.categoryName_ar}}

-
-
+ + +
+
+
+
+ + +
+
+

{{key.categoryName_en}}

+

{{key.categoryName_ar}}

+
-
- +
+ +
- - - - - -
- {{item.Title}} -
- - -
-
- {{item.Discount}} -
- - -

{{ts.trPK('general','offer-valid')}}

-
- -

{{ts.trPK('general','expired')}}

-
- - - -
- -
-
-
- -
-
+ + + + + +
+ {{item.Title}} +
+ + +
+
+ {{item.Discount}} +
+ + +

{{ts.trPK('general','offer-valid')}}

+
+ +

{{ts.trPK('general','expired')}}

+
+ + + +
+ +
+
+
+ +
+
- - - \ No newline at end of file + + + + + + + \ No newline at end of file diff --git a/Mohem/src/app/offersdiscount/home/home.component.ts b/Mohem/src/app/offersdiscount/home/home.component.ts index d9789ca4..3290aa8c 100644 --- a/Mohem/src/app/offersdiscount/home/home.component.ts +++ b/Mohem/src/app/offersdiscount/home/home.component.ts @@ -1,11 +1,10 @@ -import { AfterViewInit, Component, OnInit } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; +import { AfterViewInit, Component, ViewChild } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; import { ModalController } from '@ionic/angular'; -import { connectableObservableDescriptor } from 'rxjs/internal/observable/ConnectableObservable'; import { CommonService } from 'src/app/hmg-common/services/common/common.service'; import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; -import { FilterComponent } from '../filter/filter.component'; import { OfferDiscountService } from '../services/service'; +import { IonInfiniteScroll } from '@ionic/angular'; @Component({ selector: 'app-home', @@ -13,6 +12,9 @@ import { OfferDiscountService } from '../services/service'; styleUrls: ['./home.component.scss'], }) export class HomeComponent implements AfterViewInit { + + @ViewChild(IonInfiniteScroll) infiniteScroll: IonInfiniteScroll; + segment: any = '1'; categoriesObj: any; categories: any = []; @@ -21,8 +23,15 @@ export class HomeComponent implements AfterViewInit { tempSearch: any = []; searchText: String; direction: any; + itemCounter = 1; + itemType: any; // categories:any = []; - constructor(public ts: TranslatorService, public modalController: ModalController, public cs: CommonService, public offersService: OfferDiscountService, public route: ActivatedRoute) { + constructor( + public ts: TranslatorService, + public modalController: ModalController, + public cs: CommonService, + public offersService: OfferDiscountService, + public route: ActivatedRoute) { this.route .params.subscribe(val => { @@ -35,8 +44,10 @@ export class HomeComponent implements AfterViewInit { ngAfterViewInit(): void { this.getOfferDiscount(); } + ionEnter() { this.direction = TranslatorService.getCurrentDirection(); + console.log(this.direction); let activeClass = this.cs.sharedService.getSharedData(OfferDiscountService.selected_filters); // if (activeClass) { @@ -46,8 +57,8 @@ export class HomeComponent implements AfterViewInit { this.tempSearch = JSON.parse(JSON.stringify(this.offersData)); } getCategories() { - this.offersService.getCategories(() => { }, this.ts.trPK('general', 'retry')).subscribe((result) => { - this.categories = JSON.parse(result.Mohemm_ITG_ResponseItem).result.data; + this.offersService.getCategories({}).subscribe((result) => { + this.categories = JSON.parse(result.Mohemm_ITG_ResponseItem).result.data; //result.result.data; this.cs.sharedService.setSharedData(this.categories, OfferDiscountService.categories); }); } @@ -59,60 +70,54 @@ export class HomeComponent implements AfterViewInit { this.cs.navigateForward('/offersdiscount/offer-details'); } - getOfferDiscount() { + + getOfferDiscount(pageNo?, categoryId?) { this.cs.startLoading(); - this.offersService.getOffers({}, () => { }, this.ts.trPK('general', 'retry')).subscribe((res) => { - var data = JSON.parse(res['Mohemm_ITG_ResponseItem']); - this.cs.stopLoading(); - if (data['result']) - this.displayOffers(data['result']); - }); + if (categoryId) { + this.offersService.getOffers({}, () => { }, this.ts.trPK('general', 'retry'),pageNo, categoryId).subscribe((res) => { + var data = JSON.parse(res['Mohemm_ITG_ResponseItem']); + this.cs.stopLoading(); + if (data['result']) + this.displayOffers(data['result']); + }); + } else { + this.offersService.getOffers({}, () => { }, this.ts.trPK('general', 'retry')).subscribe((res) => { + var data = JSON.parse(res['Mohemm_ITG_ResponseItem']); + this.cs.stopLoading(); + if (data['result']) + this.displayOffers(data['result']); + }); + } } + displayOffers(data) { if (data['data']) { var parseJSON = data['data']; var offers = JSON.parse(parseJSON); this.offersData = offers; - // this.categoriesObj = this.groupBy(offers, TranslatorService.getCurrentDirection() == 'ltr' ? 'categoryName_en' : 'categoryName_ar'); - // = Object.keys(this.categoriesObj); - - - - // for (var x in this.categoriesObj) { - // for (var y in offers) { - // if (x == offers[y].categoryName_en && this.categories.filter(item => item.name.includes(x)) == false) { - // this.categories.push({ - // name: x, - // icon: offers[y].icon - // }) - - // } - // } - // } - - //this.filterOffers(this.categories[0]); } } - // groupBy(xs, key) { - // return xs.reduce((rv, x) => { - // (rv[x[key.trim()]] = rv[x[key]] || []).push(x); - // return rv - // }, {}); - // }; filterOffers(key) { - this.activeClass = key.categoryName_en; - //this.offersData = this.categoriesObj[key.name]; - this.tempSearch = JSON.parse(JSON.stringify(this.offersData)); + if(this.direction === 'ltr') { + this.activeClass = key.categoryName_en; + }else { + this.activeClass = key.categoryName_ar + } + this.itemType = key.id; + this.getOfferDiscount(1,this.itemType) } + checkDate(date) { return new Date(date) >= new Date() } + getDotted(temp) { temp = this.stripHtml(temp); return temp.substring(0, 70) + " ..."; } + stripHtml(html) { var temporalDivElement = document.createElement("div"); @@ -120,14 +125,15 @@ export class HomeComponent implements AfterViewInit { return temporalDivElement.textContent || temporalDivElement.innerText || ""; } - search(t) { + search(t) { this.offersData = this.tempSearch.filter((post, index) => { if (post.Title.toLowerCase().indexOf(t.toLowerCase()) > -1) return true; }); } + async openModel() { // const modal = await this.modalController.create({ // component: FilterComponent, @@ -137,4 +143,45 @@ export class HomeComponent implements AfterViewInit { // modal.present(); this.cs.navigateForward('/offersdiscount/filter-page'); } + + loadData(event) { + const counter = 1; + this.itemCounter += counter; + console.log(this.itemType); + if (this.itemType) { + setTimeout(() => { + event.target.complete(); + console.log(this.itemCounter); + this.offersService.getOffers({}, () => { }, this.ts.trPK('general', 'retry'), this.itemCounter, this.itemType).subscribe((res) => { + const data = JSON.parse(res['Mohemm_ITG_ResponseItem']); + if (data['result']){ + const allItem = JSON.parse(data.result['data']); + if (allItem) { + allItem.forEach(element => { + this.offersData.push(element); + }); + } + } + }); + // event.target.disabled = true; + }, 1000); + } else { + setTimeout(() => { + event.target.complete(); + console.log(this.itemCounter); + this.offersService.getOffers({}, () => { }, this.ts.trPK('general', 'retry'), this.itemCounter).subscribe((res) => { + const data = JSON.parse(res['Mohemm_ITG_ResponseItem']); + if (data['result']){ + const allItem = JSON.parse(data.result['data']); + if (allItem) { + allItem.forEach(element => { + this.offersData.push(element); + }); + } + } + }); + // event.target.disabled = true; + }, 1000); + } + } } diff --git a/Mohem/src/app/offersdiscount/services/service.ts b/Mohem/src/app/offersdiscount/services/service.ts index 01e4e092..7aae3117 100644 --- a/Mohem/src/app/offersdiscount/services/service.ts +++ b/Mohem/src/app/offersdiscount/services/service.ts @@ -15,6 +15,8 @@ export class OfferDiscountService { public static related_offers = 'related-offers'; public static selected_filters = 'selected-filters'; public static categories = 'categories'; + public static getCategories = 'Services/COCWS.svc/REST/Mohemm_ITG_GetCategories'; + constructor( public con: ConnectorService, private authService: AuthenticationService, @@ -23,23 +25,35 @@ export class OfferDiscountService { this.cs.sharedService.getSharedData(OfferDiscountService.selected_offers, false); } - getOffers(offer_request, onError, errorLabel) { + getOffers(offer_request, onError, errorLabel, pageNo?: number, categoryId?) { + let catId = categoryId; var request = this.authService.getAuthenticatedRequest(); request['EmployeeNumber'] = request.UserName; + request['ItgIsActive'] = true; + request['ItgPageSize'] = 5; + request['ItgPageNo'] = pageNo; + if (catId) { + request['ItgCategoryID'] = categoryId; + } return this.con.postNoLoad(OfferDiscountService.offersDiscountData, request, onError, errorLabel); } - getCategories(onError, errorLabel) { - var request = this.authService.getAuthenticatedRequest(); + getCategories(request: any, onError?: any, errorLabel?: string): Observable { + this.authService.authenticateRequest(request); request['EmployeeNumber'] = request.UserName; - request["ItgIsActive"] = true; - request["ItgPageSize"] = 100; - request["ItgPageNo"] = 1; - request["ItgId"] = 0; - - return this.con.postNoLoad(OfferDiscountService.categoryList, request, onError, errorLabel); - - + request['ItgChannelId'] = 3; + request['ItgIsActive'] = true; + request['ItgPageSize'] = 100; + request['ItgPageNo'] = 1; + request['ItgId'] = 0; + request['ItgCategoryName_en'] = ''; + request['ItgCategoryName_ar'] = ''; + return this.con.postNoLoad( + OfferDiscountService.getCategories, + request, + onError, + errorLabel + ); } } \ No newline at end of file diff --git a/Mohem/src/app/profile/add-basic-details/add-basic-details.component.html b/Mohem/src/app/profile/add-basic-details/add-basic-details.component.html index e4082aa9..ce1335e8 100644 --- a/Mohem/src/app/profile/add-basic-details/add-basic-details.component.html +++ b/Mohem/src/app/profile/add-basic-details/add-basic-details.component.html @@ -1,20 +1,3 @@ - - + + Effective Date + {{showEffectiveDate}} +
+
- + {{'vacation-rule, next-label' | translate}}
\ No newline at end of file diff --git a/Mohem/src/app/profile/add-basic-details/add-basic-details.component.scss b/Mohem/src/app/profile/add-basic-details/add-basic-details.component.scss index 9b59e3d3..a6dbf815 100644 --- a/Mohem/src/app/profile/add-basic-details/add-basic-details.component.scss +++ b/Mohem/src/app/profile/add-basic-details/add-basic-details.component.scss @@ -37,4 +37,9 @@ width: 80% !important; color: white!important; border-radius: 16px !important; + } + + .country{ + margin-top: 10px; + padding: 10px; } \ No newline at end of file diff --git a/Mohem/src/app/profile/add-basic-details/add-basic-details.component.ts b/Mohem/src/app/profile/add-basic-details/add-basic-details.component.ts index 5592e376..2e1f8ea0 100644 --- a/Mohem/src/app/profile/add-basic-details/add-basic-details.component.ts +++ b/Mohem/src/app/profile/add-basic-details/add-basic-details.component.ts @@ -22,6 +22,8 @@ import { EIT_ACTION } from "../models/submit.eit.action"; import { AddEitResponse } from "../models/add.eit.response"; import { element } from '@angular/core/src/render3'; import { EITNotificatonBodyResponse } from "../models/EITNotificationBodyRes"; +import { ActivatedRoute } from '@angular/router'; + @Component({ selector: 'app-add-basic-details', templateUrl: './add-basic-details.component.html', @@ -29,14 +31,13 @@ import { EITNotificatonBodyResponse } from "../models/EITNotificationBodyRes"; }) export class AddBasicDetailsComponent implements OnInit { @ViewChild("containerDiv") containerDiv: ElementRef; + @ViewChild("containerDivTwo") containerDivTwo: ElementRef; + - ////*new add*///// getPassNotificationDetails: any; getPassdirfromNotifiPage: boolean = false; functionName: string = ""; menuType: any; - ///////////////// - private textArea: TextAreaInput; private numberInput: NumberInput; private textInput: TextInput; @@ -47,7 +48,8 @@ export class AddBasicDetailsComponent implements OnInit { private buttonInput: ButtonInput; private hiddenInput: HiddenInput; private eitResponse: any; - + private eitColResponse: any; + private eitVALSettoCall: any = []; private comtransNo: number = 0; getPassMnuEntryObj: MenuEntry; @@ -64,6 +66,11 @@ export class AddBasicDetailsComponent implements OnInit { private updatedValues: any = []; addEITData: any; direction:string; + public targetValue: any; + public employeeBasicDetails: any = []; + public mutualBasicDetailsArray: any = []; + public effectiveDate: string; + public showEffectiveDate: string; constructor( @@ -71,8 +78,18 @@ export class AddBasicDetailsComponent implements OnInit { public cs: CommonService, private ts: TranslatorService, private profileService: ProfileService, - public datePicker: DatePicker + public datePicker: DatePicker, + public router: ActivatedRoute ) { + + this.router.queryParams.subscribe(params => { + this.targetValue = params.targetValue; + console.log(this.targetValue); + }); + + this.employeeBasicDetails = this.cs.sharedService.getSharedData('employeeDetails', false); + console.log(this.employeeBasicDetails); + this.direction = TranslatorService.getCurrentLanguageName(); this.selEmp = this.cs.sharedService.getSharedData( MenuResponse.SHARED_SEL_EMP, @@ -89,7 +106,6 @@ export class AddBasicDetailsComponent implements OnInit { ); this.addEITData = this.cs.sharedService.getSharedData("AddEITData", false); console.log("addEITData: " + this.addEITData); - // console.log("dirfromNotificationPage: " + this.addEITData.dirfromNotificationPage); this.basicRequest = new BasicRequest(); @@ -122,9 +138,7 @@ export class AddBasicDetailsComponent implements OnInit { ngOnInit() {} ngAfterViewInit() { - // this.getEitDffStructure(); - this.getColumnStructure(); - + this.getEitDffStructure(); } public getColumnStructure() { @@ -153,18 +167,210 @@ export class AddBasicDetailsComponent implements OnInit { public handleBasicColStructureResult(result) { if (result.GetBasicDetColsStructureList != null) { - this.eitResponse = result.GetBasicDetColsStructureList; - this.drawEitFields(result.GetBasicDetColsStructureList); + this.eitColResponse = result.GetBasicDetColsStructureList; + this.drawEitFieldsStatic(result.GetBasicDetColsStructureList); } } public handleBasicDffStructureResult(result) { if (result.GetBasicDetDffStructureList != null) { + this.getColumnStructure(); this.eitResponse = result.GetBasicDetDffStructureList; this.drawEitFields(result.GetBasicDetDffStructureList); } } + private drawEitFieldsStatic(feildsList) { + const containerId = "containerDivTwo"; + this.eitVALSettoCall = []; + for (let i = 0; i < feildsList.length; i++) { + let defaultVal: string = ""; + let defaultValText: string = ""; + + if (feildsList[i].DISPLAY_FLAG != "N") { + //text , date , time + if (feildsList[i].DATATYPE == "VARCHAR2" && feildsList[i].ObjectValuesList === null) { + // character + this.textInput = new TextInput( + feildsList[i].SEGMENT_PROMPT, + feildsList[i].APPLICATION_COLUMN_NAME, + defaultVal, + containerId, + defaultValText, + feildsList[i].MOBILE_ENABLED, + feildsList[i].DISPLAY_FLAG, + feildsList[i].REQUIRED_FLAG + ); + } else if (feildsList[i].DATATYPE == "VARCHAR2" && feildsList[i].ObjectValuesList !== null) { + this.selectInput = new SelectInput( + feildsList[i].SEGMENT_PROMPT, + feildsList[i].APPLICATION_COLUMN_NAME, + defaultVal, + containerId, + feildsList[i].MOBILE_ENABLED, + feildsList[i].DISPLAY_FLAG, + feildsList[i].REQUIRED_FLAG + ); + this.fillStaticDropdownList( + feildsList[i].SEGMENT_NAME, + feildsList[i].ObjectValuesList, + feildsList[i].APPLICATION_COLUMN_NAME + ); + } else if (feildsList[i].DATATYPE == "NUMBER") { + this.numberInput = new NumberInput( + feildsList[i].SEGMENT_PROMPT, + feildsList[i].APPLICATION_COLUMN_NAME, + defaultVal, + containerId, + feildsList[i].MOBILE_ENABLED, + feildsList[i].DISPLAY_FLAG, + feildsList[i].REQUIRED_FLAG + ); + } else if (feildsList[i].DATATYPE == "DATE" && this.targetValue === 'new') { + this.dateInput = new DateInput( + feildsList[i].SEGMENT_PROMPT, + feildsList[i].APPLICATION_COLUMN_NAME, + "", + containerId, + feildsList[i].MOBILE_ENABLED, + feildsList[i].DISPLAY_FLAG, + feildsList[i].REQUIRED_FLAG, + this.direction + ); + + } + } + } + this.fillBasicDetailsStructure(); + } + + public getElementsStaticValues(): any { + this.updatedValues = []; //fill updated list + let valuseArr: any = []; + let varcharValue: any = null; + let numbervalue: any = 0; + let dateValue: any = null; + let transNo: number = 1; + let textValue : any; + + for (let i = 0; i < this.eitColResponse.length; i++) { + varcharValue = null; + numbervalue = null; + dateValue = null; + + if (this.eitColResponse[i].DISPLAY_FLAG != "N") { + if (this.eitColResponse[i].ObjectValuesList === null) { + let elem = document.getElementById( this.eitColResponse[i].APPLICATION_COLUMN_NAME) as HTMLInputElement; + let elemVal = elem !== null ? (document.getElementById( this.eitColResponse[i].APPLICATION_COLUMN_NAME ) as HTMLInputElement).value : ''; + textValue = elemVal; + + if (this.eitColResponse[i].DATATYPE == "VARCHAR2" || this.eitColResponse[i].DATATYPE == "NUMBER") { + elemVal = elemVal; + } else if (this.eitColResponse[i].DATATYPE == "DATE" && this.targetValue === 'new') { + // date + elemVal = this.cs.formatDate(elemVal); + } else if (this.eitColResponse[i].DATATYPE == "DATE" && this.targetValue === 'correct') { + // date + elemVal = this.customiseDate(this.effectiveDate); + } + + if (this.targetValue === 'new') { + if (this.eitColResponse[i].REQUIRED_FLAG == "Y" && !elemVal) { + elem.classList.add("requiredClassElm"); + return false; + } else { + elem.classList.remove("requiredClassElm"); + } + } + + if (this.eitColResponse[i].DATATYPE == "DATE") { + dateValue = elemVal; + } else if (this.eitColResponse[i].DATATYPE == "NUMBER") { + numbervalue = elemVal; + } else { + varcharValue = elemVal; + } + + valuseArr.push({ + TRANSACTION_NUMBER: transNo, + NAME: this.eitColResponse[i].APPLICATION_COLUMN_NAME, + VARCHAR2_VALUE: varcharValue, + NUMBER_VALUE: numbervalue, + DATE_VALUE: dateValue + }); + } else { + let x = document.getElementById(this.eitColResponse[i].APPLICATION_COLUMN_NAME) as HTMLSelectElement; + + let val = x.options[x.selectedIndex] ? x.options[x.selectedIndex].value : null; + let txt = x.options[x.selectedIndex] ? x.options[x.selectedIndex].text : null; + varcharValue = val; + textValue = txt; + + if (x !== null) { + if (this.eitColResponse[i].REQUIRED_FLAG == "Y" && !varcharValue) { + x.classList.add("requiredClassElm"); + return false; + } else { + x.classList.remove("requiredClassElm"); + } + } + + valuseArr.push({ + TRANSACTION_NUMBER: transNo, + NAME: this.eitColResponse[i].APPLICATION_COLUMN_NAME, + VARCHAR2_VALUE: varcharValue, + NUMBER_VALUE: numbervalue, + DATE_VALUE: dateValue + }); + } + } else { + let x = document.getElementById(this.eitColResponse[i].APPLICATION_COLUMN_NAME) as HTMLSelectElement; + let val = x !== null ? x.dataset.colmText : ''; + textValue = x !== null ? x.value : ''; + + if (x !== null) { + if (this.eitResponse[i].REQUIRED_FLAG == "Y" && !val) { + x.classList.add("requiredClassElm"); + return false; + } else { + x.classList.remove("requiredClassElm"); + } + } + + let staticValueBasicDetail = this.employeeBasicDetails.find( + x => + x.APPLICATION_COLUMN_NAME == + this.eitColResponse[i].APPLICATION_COLUMN_NAME + ); + + if (staticValueBasicDetail) { + if (this.eitColResponse[i].DATATYPE === 'VARCHAR2') { + varcharValue = staticValueBasicDetail.VARCHAR2_VALUE; + } else if (this.eitColResponse[i].DATATYPE === 'DATE') { + dateValue = staticValueBasicDetail.DATE_VALUE; + } else if (this.eitColResponse[i].DATATYPE === 'NUMBER') { + numbervalue = staticValueBasicDetail.NUMBER_VALUE; + } else { + varcharValue = val; + } + } else { + varcharValue = val; + } + + + + valuseArr.push({ + TRANSACTION_NUMBER: transNo, + NAME: this.eitColResponse[i].APPLICATION_COLUMN_NAME, + VARCHAR2_VALUE: varcharValue, + NUMBER_VALUE: numbervalue, + DATE_VALUE: dateValue + }); + } + } + return valuseArr; + } + private drawEitFields(feildsList) { const containerId = "containerDiv"; this.eitVALSettoCall = []; @@ -375,7 +581,6 @@ export class AddBasicDetailsComponent implements OnInit { } closeModal() { - console.log("closeModal"); this.updatedValues = []; this.modalController.dismiss(); } @@ -407,6 +612,7 @@ export class AddBasicDetailsComponent implements OnInit { err => console.log("Error occurred while getting date: ", err) ); } + public showTimePicker(elemID, maxSize) { let elem = document.getElementById(elemID) as HTMLDivElement; let date: any; @@ -480,6 +686,21 @@ export class AddBasicDetailsComponent implements OnInit { } } + public fillStaticDropdownList(segmentName, optionList: any = [], elemID: string) { + let eitObj: any; + if (optionList.length > 0) { + let select = document.getElementById(elemID) as HTMLSelectElement; + document.getElementById(elemID).innerHTML = ""; + + for (let i = 0; i < optionList.length; i++) { + var option = document.createElement("option"); + option.text = optionList[i].MEANING; + option.value = optionList[i].CODE; + select.add(option); + } + } + } + bindHtmlElemEvents(id, obj) { const elem = document.getElementById(id); console.log(elem); @@ -949,6 +1170,7 @@ export class AddBasicDetailsComponent implements OnInit { } return isSt; } + isStandardDateTime(obj: any): boolean { let isSt: boolean = false; if (obj.FORMAT_TYPE == "Y") { @@ -965,6 +1187,7 @@ export class AddBasicDetailsComponent implements OnInit { } return isSt; } + isStandardTime(obj: any): boolean { let isSt: boolean = false; if (obj.FORMAT_TYPE == "I") { @@ -986,33 +1209,82 @@ export class AddBasicDetailsComponent implements OnInit { let isSt: boolean = false; if (obj.FORMAT_TYPE == "X") { // standard date - // if(obj.DEFAULT_TYPE=="C" || obj.DEFAULT_TYPE=="D" || obj.DEFAULT_TYPE=="P"||obj.DEFAULT_TYPE=="S"){//constant isSt = true; // } } return isSt; } + isStandardDateTimeVal(obj: any): boolean { let isSt: boolean = false; if (obj.FORMAT_TYPE == "Y") { // standard date time - //if(obj.DEFAULT_TYPE=="C" || obj.DEFAULT_TYPE=="D" || obj.DEFAULT_TYPE=="P"||obj.DEFAULT_TYPE=="S"){//constant isSt = true; - //} } return isSt; } + isStandardTimeVal(obj: any): boolean { let isSt: boolean = false; if (obj.FORMAT_TYPE == "I") { // standard time - //if(obj.DEFAULT_TYPE=="C" || obj.DEFAULT_TYPE=="D" || obj.DEFAULT_TYPE=="P"||obj.DEFAULT_TYPE=="S"){//constant isSt = true; - //} } return isSt; } + public customiseDate(date: any) { + let formatedDate = date.slice(0,9); + let newDate = formatedDate.split("/").reverse(); + const tmp = newDate[2]; + newDate[2] = newDate[1]; + newDate[1] = tmp; + newDate = newDate.join("/"); + newDate = newDate + ' 00:00:00'; + return newDate; + } + + + public fillBasicDetailsStructure() { + + this.mutualBasicDetailsArray = this.mutualBasicDetailsArray.concat(this.eitResponse, this.eitColResponse); + + for (let i = 0; i < this.employeeBasicDetails.length; i++) { + let val: any; + if (this.employeeBasicDetails[i].VARCHAR2_VALUE) { + val = this.employeeBasicDetails[i].VARCHAR2_VALUE; + } else if (this.employeeBasicDetails[i].DATE_VALUE) { + val = this.customiseDate(this.employeeBasicDetails[i].DATE_VALUE); + if (this.employeeBasicDetails[i].APPLICATION_COLUMN_NAME === 'EFFECTIVE_DATE') { + this.effectiveDate = this.employeeBasicDetails[i].DATE_VALUE; + this.showEffectiveDate = this.employeeBasicDetails[i].SEGMENT_VALUE_DSP; + } + } else if (this.employeeBasicDetails[i].NUMBER_VALUE) { + val = this.employeeBasicDetails[i].NUMBER_VALUE; + } + const elem = document.getElementById( this.employeeBasicDetails[i].APPLICATION_COLUMN_NAME ) as HTMLInputElement; + if (elem) { + if (val) { + let feldDetails = this.mutualBasicDetailsArray.find( + x => + x.APPLICATION_COLUMN_NAME == + this.employeeBasicDetails[i].APPLICATION_COLUMN_NAME + ); + if (feldDetails) { + let isStandardTime = this.isStandardTimeVal(feldDetails); + if (isStandardTime) { + elem.innerHTML = val; + elem.dataset.dtvalue = val; + } else { + elem.value = val; + elem.setAttribute("value", elem.value); + } + } + } + } + } + } + fillEITStructure() { var obj = { peiObjVer: null, peiExtraInfoID: null }; for (let i = 0; i < this.validateEitObj.length; i++) { @@ -1094,7 +1366,7 @@ export class AddBasicDetailsComponent implements OnInit { let varcharValue: any = null; let numbervalue: any = 0; let dateValue: any = null; - let transNo: number = this.comtransNo; + let transNo: number = 1; let textValue : any; // if(this.ExtraObj.transactionNo) // transNo=this.ExtraObj.transactionNo; @@ -1214,7 +1486,28 @@ export class AddBasicDetailsComponent implements OnInit { } else { x.classList.remove("requiredClassElm"); } - if (val) varcharValue = val; + + let staticValueBasicDetail = this.employeeBasicDetails.find( + x => + x.APPLICATION_COLUMN_NAME == + this.eitResponse[i].APPLICATION_COLUMN_NAME + ); + + if (staticValueBasicDetail) { + if (staticValueBasicDetail.DATATYPE === 'VARCHAR2') { + varcharValue = staticValueBasicDetail.VARCHAR2_VALUE; + } else if (staticValueBasicDetail.DATATYPE === 'DATE') { + dateValue = staticValueBasicDetail.DATE_VALUE; + } else if (staticValueBasicDetail.DATATYPE === 'NUMBER') { + numbervalue = staticValueBasicDetail.NUMBER_VALUE; + } else { + if (val) varcharValue = val; + } + } else { + if (val) varcharValue = val; + } + + valuseArr.push({ TRANSACTION_NUMBER: transNo, NAME: this.eitResponse[i].APPLICATION_COLUMN_NAME, @@ -1384,6 +1677,7 @@ export class AddBasicDetailsComponent implements OnInit { values.push(obj3); return values; } + fillExtraInformation( values: any, peiAction: string, @@ -1415,16 +1709,6 @@ export class AddBasicDetailsComponent implements OnInit { return values; } - submitEit() { - let list = this.basicRequest.EITTransactionTBL; - this.basicRequest.EITTransactionTBL = this.fixTransactionNo(list); - this.profileService - .submitEit(this.basicRequest) - .subscribe((result: AddEitResponse) => { - this.handleSubmitEitResult(result); - }); - } - fixTransactionNo(transactionTBL: any): any[] { let list: any = []; let newIndex: number = 1; @@ -1453,78 +1737,37 @@ export class AddBasicDetailsComponent implements OnInit { } return list; } - handleSubmitEitResult(result) { + + public handleBasicdetailsResult(result) { if (this.cs.validResponse(result)) { - this.cs.sharedService.setSharedData( - this.basicRequest, - BasicRequest.SHARED_DATA - ); - this.cs.sharedService.setSharedData(result, AddEitResponse.SHARED_DATA); - //this.addrespList=result.SubmitEITTransactionList; - // this.itemKey=this.addrespList.P_ITEM_KEY; - // this.P_TransactionID=result.SubmitEITTransactionList.P_TRANSACTION_ID; - // this.sharedData.setSharedData(result,AddEitResponse.SHARED_DATA); - - // // this.sharedData.setSharedData(result.SubmitEITTransactionList.P_TRANSACTION_ID,"TransactionIDResubmit"); - // // this.sharedData.setSharedData(this.eitRequest,EitRequest.SHARED_DATA); - - this.cs.sharedService.setSharedData( - { isResubmit: false }, - "confirmAddEITData" - ); - this.cs.openConfirmEitPage(); - // this.navCtrl.push("ConfirmAddEitPage", { isResubmit: false }); + this.cs.sharedService.setSharedData(this.basicRequest, BasicRequest.SHARED_DATA); + this.cs.sharedService.setSharedData(result.SubmitBasicDetTransactionList, 'basic-details-response'); + // this.cs.sharedService.setSharedData({ isResubmit: false },"confirmAddEITData"); + this.cs.openConfirmBasicDetailsPage(); } } - // validateEITTransaction() { - // // let EITTransactionValues:any= []; - - // this.arrValues = this.getElementsValues(); - // if (this.arrValues) { - // this.basicRequest = { - // P_SELECTED_EMPLOYEE_NUMBER: this.selEmp, - // P_MENU_TYPE: this.menuType, - // P_SELECTED_RESP_ID: this.respID, //this.selMenu.List_Menu.RESP_ID,//-999, - // P_FUNCTION_NAME: this.functionName, - // P_DESC_FLEX_CONTEXT_CODE: this.eitResponse[0].DESC_FLEX_CONTEXT_CODE, - // EITTransactionTBL: this.arrValues - // }; - - // this.eitService - // .validateEITTransaction(this.eitRequest) - // .subscribe((result: any) => { - // this.handleEITValidateTr(result); - // }); - // } - // } - // private handleEITValidateTr(result) { - // let data: any = { eitRequest: {}, updated: [] }; - // if (this.cs.validResponse(result)) { - // // public static SHARED_DATA = 'login-request'; - // this.cs.sharedService.setSharedData( - // this.eitRequest, - // EitRequest.SHARED_DATA - // ); - // if (this.getPassdirfromNotifiPage) { - // let data: any = { eitRequest: {}, updated: [] }; - // data.eitRequest = this.eitRequest; - // data.updated = this.updatedValues; - // // this.viewCtrl.dismiss(data); - // this.modalController.dismiss(data); - // // this.closemodal(); - // } else { - // this.submitEit(); - // // this.navCtrl.push("ConfirmAddEitPage"); - // // data = { eitRequest: {}, updated: [] }; - // // data.eitRequest = this.eitRequest; - // // data.updated = this.updatedValues; - // // this.viewCtrl.dismiss(data); - // } - // } else { - // this.updatedValues = []; - // data = { eitRequest: {}, updated: [] }; - // } - // } + public submitBasicDetailsTransaction() { + this.arrValues = this.getElementsValues(); + let staticValues = this.getElementsStaticValues(); + let allStatisDynamicValues = this.arrValues.concat(staticValues); + + if (allStatisDynamicValues) { + this.basicRequest = { + P_SELECTED_EMPLOYEE_NUMBER: this.selEmp, + P_MENU_TYPE: this.selMenu.List_Menu.MENU_TYPE, + P_SELECTED_RESP_ID: this.respID, + P_FUNCTION_NAME: this.selMenu.GetMenuEntriesList.FUNCTION_NAME, + EITTransactionTBL: allStatisDynamicValues, + P_ACTION_TYPE: this.targetValue === 'correct' ? 'CORRECT' : 'CHANGE' + }; + console.log(this.basicRequest); + + this.profileService.submitBasicDetailsTransaction(this.basicRequest).subscribe((result: any) => { + this.handleBasicdetailsResult(result); + }); + } + } + } diff --git a/Mohem/src/app/profile/confirm-basic-details/confirm-basic-details.component.html b/Mohem/src/app/profile/confirm-basic-details/confirm-basic-details.component.html index 4e678a53..5a222666 100644 --- a/Mohem/src/app/profile/confirm-basic-details/confirm-basic-details.component.html +++ b/Mohem/src/app/profile/confirm-basic-details/confirm-basic-details.component.html @@ -1,3 +1,128 @@ -

- confirm-basic-details works! -

+ + + + {{headerTitle}} + + + + + + + + + +
{{'general, addAttach' | translate}}
+
+ +
+ +
+
+
+ + + {{ 'general, notAttch' | translate}} + +
+ + +
+ + + + {{attachList.AttachmentID +1 }} . + + + + + {{attachList.P_FILE_NAME }} + + + + + + + +
+ +
+ +
+ + +
+
+ + {{attachRes.FILE_NAME }} + +
+ + + + +
+
+ +
+ + + +
{{'confirmAddEit, comment' | translate}}
+ + + +
+ + +
{{'confirmAddEit, approverList' | translate}}
+
+

{{ 'general, empty' | translate}}

+
+
+ +
+ + +
+
+ +
+
+ + + {{employee.APPROVER}} + + + {{employee.POSITION_TITLE}} + + + +
+
+
+
+
+ +
+ + +
+ + +
+ + {{ (isDelete ? 'general, delete' : 'general, submit') | translate }} +
+
\ No newline at end of file diff --git a/Mohem/src/app/profile/confirm-basic-details/confirm-basic-details.component.scss b/Mohem/src/app/profile/confirm-basic-details/confirm-basic-details.component.scss index e69de29b..2ed98379 100644 --- a/Mohem/src/app/profile/confirm-basic-details/confirm-basic-details.component.scss +++ b/Mohem/src/app/profile/confirm-basic-details/confirm-basic-details.component.scss @@ -0,0 +1,263 @@ +.footer-button { + border-radius: 2px; + padding: 0 1.1em; + min-height: 45px; + min-width: 200px; + } + + .imgSize { + width: 22px; + height: 22px; + } + + .Header { + font-weight: bold; + color: #1a586d !important; + font-size: 10px; + } + + .tbData { + font-size: 10px; + } + + .btnBack { + background: transparent; + float: right; + } + + .attachmentDiv{ + background: #ffffff; + height: auto; + text-align: center; + padding-top: 1px; + margin: 10px; + border-radius: 15px; + border: 1px solid grey; + } + + .noDataDiv{ + background: #ffffff; + height: 11%; + text-align: center; + padding-top: 1px; + border-radius: 10px; + margin: 10px; + border-radius: 5px; + } + .submitNote{ + background: #ffffff; + height: 80px; + padding-top: 1px; + margin: 10px; + border-radius: 15px; + border: 1px solid grey; + } + + .approvalList{ + --background: #f0efef; + height: auto; + text-align: center; + padding-top: 1px; + border-radius: 10px; + margin: 10px; + border-radius: 5px; + } + + /************************New Design**********************************/ + .notification-list{ + background: none; + background: none; + border-radius: 32px; + ion-item{ + // margin-top: 5px; + // margin-bottom: 5px; + + background-color: transparent; + .item-date{ + width: 100%; + font-size: 16px; + font-weight: bold; + + text-align: start; + padding: 0; + margin: 0; + + position: absolute; + left: 0; + top: 12%; + } + ion-label , [item-end]{ + + white-space: normal; + font-size: 14px; + padding-top: 15%; + // :root[dir="ltr"]{ + // margin-left: 10px; + // } + // :root[dir="rtl"]{ + // margin-right: 10px; + // } + + } + + } + } + + + + + + + .timeline { + position: relative; + margin: 15px 0 0 0; + // border-bottom: solid 1px var(--cusgray); + } + + .timeline:before { + + content: ''; + position: inherit !important; + top: 0; + bottom: 0; + width: 4px; + // background: #e4e4e4; + z-index: 1; + left: 35px; + /* margin-left: -10px; */ + /* z-index: 1; */ + } + + .timeline .timeline-thumb { + + border-radius: 500px; + width: 70px !important; + z-index: 2; + position: absolute; + left: 0px; + // :root[dir="ltr"]{ + // left: 37px; + // } + // :root[dir="rtl"]{ + // right: 37px; + // } + float: right; + top: 9px; + } + + .timeline .timeline-thumb.timeline-icon { + height: 70px; + // text-align: center; + // color: white; + // border: 5px solid #CBD0D3; + // transform: scale(0.2); + } + + + + .timeline .timeline-item { + width: 40px; + + } + + .timeline .timeline-stats { + position: relative; + font-size: 12px; + color: var(--darkgray); + + } + + .empImge{ + border-radius: 50%; + width:100%; + height: 100%; + border: #dedede solid 1px; + + } + .empImgeRep { + border-radius: 50% !important; + width: 80px; + height: 80px; + border: #dedede solid 1px; + } + + .line{ + padding-bottom:87px; + } + + .attachLable{ + position: absolute; + top: 0px; + z-index: 0; + background: #30b8c6; + color: #fff; + border-radius: 50%; + border: 0px; + width: 24px; + height: 24px; + text-align: center; + font-size: 5px; + } + + .removeLable{ + top: 0px; + z-index: 0; + background: #d8252d; + color: #fff; + border-radius: 50%; + border: 0px; + width: 20px; + height: 20px; + text-align: center; + font-size: 5px; + } + + .note-modal { + // width: 90%; + // height: 50%; + // top: 20%; + // left: 5%; + // right: 5%; + // bottom: 5%; + background: rgba(0, 0, 0, 0.5) !important; + padding: 30% 10% !important; + --height: 12cm !important; + // --width: 80% !important; + --border-radius:20px; + + } + .header-toolbar-new{ + --background: #269DB8; + } + .title{ + margin-top: -37px; + margin-left: 85px; + } + .title-ar{ + margin-top: -37px; + margin-right: 101px; + } + .confirmEitOkButton{ + white-space: normal !important; + text-transform: capitalize !important; + min-height: 45px !important; + min-width: 5px !important; + margin: 8px !important; + background-color: #269DB8; + width: 80% !important; + color: white!important; + border-radius: 16px !important; + } + + .approvalTitle-ar{ + font-weight: bold; + font-size: 16px; + text-align: right; + + } + .approvalTitle{ + font-weight: bold; + font-size: 16px; + text-align: left; + } + \ No newline at end of file diff --git a/Mohem/src/app/profile/confirm-basic-details/confirm-basic-details.component.ts b/Mohem/src/app/profile/confirm-basic-details/confirm-basic-details.component.ts index 97213ee6..ef49d9e4 100644 --- a/Mohem/src/app/profile/confirm-basic-details/confirm-basic-details.component.ts +++ b/Mohem/src/app/profile/confirm-basic-details/confirm-basic-details.component.ts @@ -1,4 +1,20 @@ import { Component, OnInit } from '@angular/core'; +import { ModalController } from '@ionic/angular'; +import { FileUploader } from 'ng2-file-upload'; +import { AddAttachComponent } from 'src/app/eit/add-attach/add-attach.component'; +import { AddEitResponse } from 'src/app/eit/models/add.eit.response'; +import { BasicRequest } from "../models/basic.request"; +import { NotificationGetAttachResponse } from 'src/app/eit/models/NotificationGetAttachRes'; +import { EitService } from 'src/app/eit/services/eit.service'; +import { SubmitEitModalComponent } from 'src/app/eit/submit-eit-modal/submit-eit-modal.component'; +import { CommonService } from 'src/app/hmg-common/services/common/common.service'; +import { MenuResponse } from 'src/app/hmg-common/services/menu/models/menu-response'; +import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; +import { EITNotificatonBodyResponse } from 'src/app/notification/models/EITNotificationBodyRes'; +import { WorkListButtonRequest } from 'src/app/notification/models/NotificationButtonReq'; +import { WorkListAttachViewComponent } from 'src/app/notification/work-list-attach-view/work-list-attach-view.component'; +import { ProfileService } from '../service/profile.service'; +import { SubmitAddressModalComponent } from '../submit-eit-modal/submit-address-modal.component'; @Component({ selector: 'app-confirm-basic-details', @@ -7,8 +23,413 @@ import { Component, OnInit } from '@angular/core'; }) export class ConfirmBasicDetailsComponent implements OnInit { - constructor() { } + private P_TransactionID: number; + private basicRequest: BasicRequest; + approversList = []; + basicResponseList: any; + eitComments: string = ""; + menuType: string = ""; + selEmp: string = ""; + respID: number; + selMenu: MenuResponse; + getAttachList: any; + attachListDisplay: any = []; + headerTitle: string = ""; + isTrue: any = 0; + attachItems: any; + public isResubmitEIT: boolean = false; + private itemKey: string = ""; + private pActionMode: string = "SUBMIT"; + attachReqObj: WorkListButtonRequest = new WorkListButtonRequest(); + attachmentRes: any; + objIndex1: any; + attachListOver: any = []; + index: any = 0; + getPassNotificationDetails: any; + isSubmitBtnClicked: boolean; + // isDelete: boolean = false; - ngOnInit() {} + /***Add Attchment Vars */ + isUpload: boolean = false; + inQueue: boolean = false; + addAttachmentListReq: any; + attachmentID: number = 0; + addAttachRequest: any = []; + fileData: any; + fileType: any; + dirPage: any; + TransactionID: any; + indexLastObj: any = 0; + filterAllowedType: any = ['application/pdf', 'image/jpeg', 'image/png', 'text/plain', 'image/jpg', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']; + direction: string; + + constructor(public modalController: ModalController, public cs: CommonService, private ts: TranslatorService, private eitService: EitService, public profileService: ProfileService) { + this.direction = TranslatorService.getCurrentLanguageName() + this.isSubmitBtnClicked = false; + this.basicRequest = new BasicRequest(); + } + + ngOnInit() { + this.selMenu = this.cs.sharedService.getSharedData(MenuResponse.SHARED_DATA, false); + this.selEmp = this.cs.sharedService.getSharedData(MenuResponse.SHARED_SEL_EMP, false); + this.respID = this.cs.sharedService.getSharedData(MenuResponse.SHARED_SEL_RESP_ID, false); + this.basicRequest = this.cs.sharedService.getSharedData(BasicRequest.SHARED_DATA, false); + + this.selEmp = this.basicRequest.P_SELECTED_EMPLOYEE_NUMBER; + + this.menuType = this.selMenu.List_Menu.MENU_TYPE; + this.headerTitle = this.selMenu.GetMenuEntriesList.PROMPT; + this.basicResponseList = this.cs.sharedService.getSharedData('basic-details-response', false); + console.log(this.basicResponseList); + this.itemKey = this.basicResponseList.P_ITEM_KEY; + this.P_TransactionID = this.basicResponseList.P_TRANSACTION_ID; + // this.isDelete = this.isResubmitEIT = this.cs.sharedService.getSharedData('confirmAddEITData', false).isDelete; + + this.getApproversList(); + + } + + getApproversList() { + let body: any = { + P_TRANSACTION_ID: this.P_TransactionID, + P_AME_TRANSACTION_TYPE: "SSHRMS", + P_PAGE_NUM: 1, + P_PAGE_LIMIT: 1000 + } + this.eitService.getApproversList(body).subscribe((result: any) => { + this.handleApproversResult(result); + }); + } + + handleApproversResult(result) { + if (this.cs.validResponse(result)) { + this.approversList = result.GetApprovesList; + } + } + + startEitApproval() { + if (this.attachListOver) { + let request = { + AddAttachmentList: this.attachListOver + } + + this.eitService.addAttachment( + request). + subscribe((result: any) => { + this.handleAddAttachmentResults(result); + }); + } else { + this.startBasicDetailsApprovalProcess(); + } + } + + + handleAddAttachmentResults(result) { + + if (this.cs.validResponse(result)) { + this.isTrue = 0; + for (let i = 0; i < result.AddAttSuccessList.length; i++) { + if (!result.AddAttSuccessList[i].AddSuccess) { + this.attachListOver[i].isSuccess = false; + //this.attachItems[i].isSuccess = false; + // if false display cancel button with waring icon or design + }// end if + else { + // if true remove cancel and set isSuccess = true + // this.attachItems[i].isSuccess = true; + this.attachListOver[i].isSuccess = true; + this.isTrue = this.isTrue + 1; //count flag of attach status + } // end else + } // end for + + if (this.isTrue == result.AddAttSuccessList.length) { + this.startBasicDetailsApprovalProcess(); + } + else { + //stope + let filtered = this.attachListOver.filter(function (el) { return el.isSuccess == true; }); + this.attachListOver = filtered; + let msg: string = ""; + msg = this.ts.trPK("eit", "attach-errorMsg"); + this.cs.presentAlert(msg); + } + } + } + + startBasicDetailsApprovalProcess() { + let request: any = {}; + request.P_SELECTED_EMPLOYEE_NUMBER = this.selEmp; + request.P_MENU_TYPE = this.menuType; + request.P_SELECTED_RESP_ID = this.respID; + request.P_TRANSACTION_ID = this.P_TransactionID; + request.P_ITEM_KEY = this.itemKey; + request.P_ACTION_MODE = this.pActionMode; + request.P_COMMENTS = this.eitComments; + this.profileService.startBasicDetailsApprovalProcess( + request). + subscribe((result: any) => { + this.handleResults(result); + }); + } + cancelEitProcess() { + let body: any = { + P_TRANSACTION_ID: this.P_TransactionID + } + this.eitService.cancelHRTransaction( + body). + subscribe((result: any) => { + this.handleCancelResults(result); + }); + + } + handleCancelResults(result) { + if (this.cs.validResponse(result)) { + this.isSubmitBtnClicked = false; + } + } + handleResults(result) { + if (this.cs.validResponse(result)) { + this.isSubmitBtnClicked = true; + let msg: string = this.ts.trPK("eit", "approval-message-success"); + this.cs.presentAlert(msg); + this.cs.openNotificationPage(); + } + } + + async addAttachment(str: boolean, attachItems: any) { + //open the modal with return data + let attachDocID = attachItems.ATTACHED_DOCUMENT_ID; + + this.cs.sharedService.setSharedData(this.P_TransactionID, 'TransactionID'); + this.cs.sharedService.setSharedData(this.attachListOver.length, 'indexLastObj'); + + const modal = await this.modalController.create({ + component: AddAttachComponent + }); + + modal.onDidDismiss() + .then((data) => { + if (data == "cancel" || data == "undefined") { + return; + } else { + if (!str) { + this.updateFile(data, attachDocID); + } else { + console.log(data); + this.attachListDisplay = data.data; + this.attachItems = this.attachListDisplay.map(function (el) { + var o = Object.assign({}, el); + o.isSuccess = false; + return o; + }); + + this.attachListOver = this.attachListOver ? this.attachListOver.concat(this.attachItems) : this.attachItems; + } + } + }); + + return await modal.present(); + } + + /*****submit modal********/ + async openSubmitModal() { + this.cs.sharedService.setSharedData(this.attachListOver, 'submitAttachmentList'); + this.cs.sharedService.setSharedData(this.eitComments, 'eitComments'); + const modal = await this.modalController.create({ + component: SubmitAddressModalComponent, + backdropDismiss: false, + + }); + modal.cssClass = 'note-modal'; + + modal.onDidDismiss() + .then((data) => { + console.log(data.data); + + if (data.data == "cancel" || data.data == undefined) { + return; + } else { + this.startEitApproval(); + } + }); + + return await modal.present(); + } + + + + removeFile(objectitem) { + if (this.attachListOver) { + let index2 = this.attachListOver.findIndex(item => item == objectitem); + if (index2 > -1) { + this.attachListOver.splice(index2, 1); + } + } + if (this.attachmentRes) { + let index3 = this.attachmentRes.findIndex(item => item == objectitem); + if (index3 > -1) { + this.attachmentRes.splice(index3, 1); + } + } + + } + + + getAttachment(NotificationID) { + this.attachReqObj.P_NOTIFICATION_ID = NotificationID; + this.eitService.getAttach(this.attachReqObj). + subscribe((result: NotificationGetAttachResponse) => { + this.handleWorkListAttachResult(result); + }); + } + + handleWorkListAttachResult(result) { + if (this.cs.validResponse(result)) { + if (result.GetAttachementList != null) { + this.attachmentRes = result.GetAttachementList; + } // if result == null + } // valid it + + } + + async OpenAttachFiles(value, Type) { + this.cs.sharedService.setSharedData({ displayData: value, TypeData: Type }, 'WorkListAttachViewPage'); + const modal = await this.modalController.create({ + component: WorkListAttachViewComponent + }); + + modal.onDidDismiss() + .then((data) => { + }); + return await modal.present(); + } + + + delelteFile(attach) { + this.cs.confirmAlertDialog((data) => { + if (data == true) { + this.continueDelete(attach); + } + }, this.ts.trPK('general', 'ok'), () => { + + }, this.ts.trPK('general', 'cancel'), this.ts.trPK('general', 'alert'), this.ts.trPK('eit', 'delete-perm')); + } + + continueDelete(attach) { + let req = { + P_ATTACHED_DOCUMENT_ID: attach.ATTACHED_DOCUMENT_ID + } + this.eitService.deleteAttach(req). + subscribe((result: any) => { + if (this.cs.validResponse(result)) { + if (result.DeleteAttachmentList.P_RETURN_STATUS === "S") { + this.getAttachment(this.getPassNotificationDetails.NOTIFICATION_ID); + let msg: string = ""; + msg = this.ts.trPK("eit", "deleteAttach"); + this.cs.presentAlert(msg); + } + } + }); + } + + updateFile(attachList, attachDocID) { + let req = { + P_ATTACHED_DOCUMENT_ID: attachDocID, + P_FILE_DATA: attachList[0].P_FILE_DATA, + P_FILE_NAME: attachList[0].P_FILE_NAME, + P_FILE_CONTENT_TYPE: attachList[0].P_FILE_CONTENT_TYPE + } + this.eitService.updateAttach(req). + subscribe((result: any) => { + if (this.cs.validResponse(result)) { + if (result.MessageStatus == 1) { + let msg: string = ""; + msg = this.ts.trPK("eit", "attachUpdate"); + this.cs.presentAlert(msg); + this.getAttachment(this.getPassNotificationDetails.NOTIFICATION_ID); + } + } + }); + } + + + ionViewWillLeave() { + if (this.P_TransactionID && this.isSubmitBtnClicked == false) + this.cancelEitProcess(); + } + + /*******************Add attchement Functions*************/ + + public uploader: FileUploader = new FileUploader({ + allowedMimeType: ['application/pdf', 'image/jpeg', 'image/png', 'text/plain', 'image/jpg', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'], + maxFileSize: 10 * 1024 * 1024, + formatDataFunctionIsAsync: true, + formatDataFunction: async (item) => { + return new Promise((resolve, reject) => { + resolve({ + name: item._file.name, + length: item._file.size, + contentType: item._file.type, + date: new Date() + }); + }); + } + }); + + + onFileSelectedclick(event) { + event.target.value = ''; + } + + + + onFileSelected(input) { + + if (!(this.filterAllowedType.indexOf(input.target.files[0].type) > -1)) { + let msg: string = ""; + msg = this.ts.trPK("general", "notSupport"); + this.cs.presentAlert(msg); + return + } // todo: show alert that you tried uploading wrong files + + else { + const file = input.target.files[0]; + this.getBase64(file).then( + data => this.pushObject(data, file.name, file.type) + ); + } + } + + + getBase64(file) { + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = () => resolve(reader.result); + reader.onerror = error => reject(error); + }); + } + + + pushObject(fileData, name, type) { + + console.log("before push: " + this.index); + try { + let array = name.split('.'); + let attachType: string = array[array.length - 1]; + this.attachListOver.push( + { + AttachmentID: this.attachListOver.length, + P_FILE_CONTENT_TYPE: attachType,//type.split('/')[1], + P_FILE_DATA: fileData.split(',')[1], + P_FILE_NAME: name,//.split('.')[0], + P_TRANSACTION_ID: this.P_TransactionID + }) + + } catch (e) { + } + } + } + diff --git a/Mohem/src/app/profile/home/home.component.html b/Mohem/src/app/profile/home/home.component.html index ccef838c..962a1fdb 100644 --- a/Mohem/src/app/profile/home/home.component.html +++ b/Mohem/src/app/profile/home/home.component.html @@ -196,8 +196,7 @@ - + diff --git a/Mohem/src/app/profile/home/home.component.ts b/Mohem/src/app/profile/home/home.component.ts index 68ca831a..626c7b98 100644 --- a/Mohem/src/app/profile/home/home.component.ts +++ b/Mohem/src/app/profile/home/home.component.ts @@ -165,6 +165,7 @@ export class HomeComponent implements OnInit { this.profileService.getEmployeeBasicDetails(body).subscribe((result: any) => { if (this.cs.validResponse(result)) { this.employeeBasicDetails = result.GetEmployeeBasicDetailsList; + this.cs.sharedService.setSharedData(this.employeeBasicDetails, 'employeeDetails'); console.log(this.employeeBasicDetails); for (let i = 0; i < this.employeeBasicDetails.length; i++) { if (this.employeeBasicDetails[i].APPLICATION_COLUMN_NAME === 'FULL_NAME') { @@ -280,7 +281,7 @@ export class HomeComponent implements OnInit { this.transactionNo++; // tslint:disable-next-line: max-line-length this.cs.sharedService.setSharedData({ dirfromNotificationPage: false, submitEITObjList: undefined, transNo: this.transactionNo }, 'AddEITData'); - this.cs.openAddBasicDetails(); + this.openAddBasicDetails(); } else { this.openAddAddress(); } @@ -297,7 +298,7 @@ export class HomeComponent implements OnInit { } } - async presentModal() { + async presentModal(source: string) { const modal = await this.modalController.create({ component: EditDetailProfileComponent, cssClass: 'my-custom-modal-css' @@ -307,14 +308,18 @@ export class HomeComponent implements OnInit { .then((data) => { console.log(data); this.cs.sharedService.setSharedData(data.data, ProfileService.SELECTED_STATUS); - if (data.data && data.data.data == 1) { + if (data.data && data.data.data == 1 && source === 'address') { this.cs.sharedService.setSharedData(this.addressSubMenu, ProfileService.ADRESS_ENTRIES); this.cs.sharedService.setSharedData(this.employeeAdress, ProfileService.EMP_ADDRESS); this.cs.sharedService.setSharedData(this.country, ProfileService.COUNTRY); this.cs.openAddAddress(); - } else if (data.data && data.data.data == 2) { + } else if (data.data && data.data.data == 2 && source === 'address') { this.cs.openAddAddress(); + } else if (data.data && data.data.data == 1 && source === 'basicDetails') { + this.cs.openAddBasicDetails('correct'); + } else if (data.data && data.data.data == 2 && source === 'basicDetails') { + this.cs.openAddBasicDetails('new'); } @@ -327,14 +332,19 @@ export class HomeComponent implements OnInit { } public openAddAddress() { - if (this.addressSubMenu && this.addressSubMenu.UPDATE_BUTTON === 'Y') { - - this.presentModal(); + this.presentModal('address'); } else { this.cs.openAddAddress(); } + } + public openAddBasicDetails() { + if (this.basicDetailsSubMenu && this.basicDetailsSubMenu.UPDATE_BUTTON === 'Y') { + this.presentModal('basicDetails'); + } else { + this.cs.openAddBasicDetails('correct'); + } } } diff --git a/Mohem/src/app/profile/models/basic.request.ts b/Mohem/src/app/profile/models/basic.request.ts index a93d7d01..68f183ec 100644 --- a/Mohem/src/app/profile/models/basic.request.ts +++ b/Mohem/src/app/profile/models/basic.request.ts @@ -6,6 +6,7 @@ export class BasicRequest { public P_SELECTED_EMPLOYEE_NUMBER: string; public P_FUNCTION_NAME: string; public P_SELECTED_RESP_ID: Number; - P_DESC_FLEX_CONTEXT_CODE: string; + // P_DESC_FLEX_CONTEXT_CODE: string; EITTransactionTBL: EitTransactionModel[]; + P_ACTION_TYPE: string; } \ No newline at end of file diff --git a/Mohem/src/app/profile/service/profile.service.ts b/Mohem/src/app/profile/service/profile.service.ts index 470bef1d..0feb9512 100644 --- a/Mohem/src/app/profile/service/profile.service.ts +++ b/Mohem/src/app/profile/service/profile.service.ts @@ -19,6 +19,7 @@ export class ProfileService { public static submitEit = 'Services/ERP.svc/REST/SUBMIT_EIT_TRANSACTION'; public static resubmitEit = 'Services/ERP.svc/REST/RESUBMIT_EIT_TRANSACTION'; public static startEitProcess = 'Services/ERP.svc/REST/START_ADDRESS_APPROVAL_PROCESS'; + public static startBasicProcess = 'Services/ERP.svc/REST/START_BASIC_DET_APPR_PROCESS'; public static updateAttach = 'Services/ERP.svc/REST/UPDATE_ATTACHMENT'; public static deleteAttach = 'Services/ERP.svc/REST/DELETE_ATTACHMENT'; public static getApproversList = 'Services/ERP.svc/REST/GET_APPROVERS_LIST'; @@ -28,8 +29,9 @@ export class ProfileService { public static getEmployeeAddress = "Services/ERP.svc/REST/GET_EMPLOYEE_ADDRESS"; public static getCountries = "Services/ERP.svc/REST/GET_COUNTRIES"; - public static getDiffStructure = "Services/ERP.svc/REST/GET_ADDRESS_DFF_STRUCTURE" - public static submitAddressTransactions = "Services/ERP.svc/REST/SUBMIT_ADDRESS_TRANSACTION" + public static getDiffStructure = "Services/ERP.svc/REST/GET_ADDRESS_DFF_STRUCTURE"; + public static submitAddressTransactions = "Services/ERP.svc/REST/SUBMIT_ADDRESS_TRANSACTION"; + public static submitBasicDetailsTransaction = "Services/ERP.svc/REST/SUBMIT_BASIC_DET_TRANSACTION"; public static ADRESS_ENTRIES = 'address-entries'; public static EMP_ADDRESS = 'emp-address'; @@ -110,9 +112,19 @@ export class ProfileService { this.authService.authenticateRequest(request); return this.con.post(ProfileService.submitAddressTransactions, request, onError, errorLabel); } + public submitBasicDetailsTransaction(basicDetailsRequest: any, onError?: any, errorLabel?: string): Observable { + const request = basicDetailsRequest; + this.authService.authenticateRequest(request); + return this.con.post(ProfileService.submitBasicDetailsTransaction, request, onError, errorLabel); + } public startEitApprovalProcess(eitProcess: any, onError?: any, errorLabel?: string): Observable { const request = eitProcess; this.authService.authenticateRequest(request); return this.con.post(ProfileService.startEitProcess, request, onError, errorLabel); } + public startBasicDetailsApprovalProcess(basicDetailsProcess: any, onError?: any, errorLabel?: string): Observable { + const request = basicDetailsProcess; + this.authService.authenticateRequest(request); + return this.con.post(ProfileService.startBasicProcess, request, onError, errorLabel); + } } \ No newline at end of file