From ded927bf6a4fab64ea57587e37e1f15788ae0618 Mon Sep 17 00:00:00 2001 From: umasoodch Date: Sun, 8 Aug 2021 17:40:18 +0300 Subject: [PATCH] fixed basic details issue --- Mohem/src/app/app.component.ts | 1 - .../services/common/common.service.ts | 3 + .../add-basic-details.component.html | 4 +- .../add-basic-details.component.ts | 177 ++++---- .../confirm-basic-details.component.html | 131 +++++- .../confirm-basic-details.component.scss | 263 +++++++++++ .../confirm-basic-details.component.ts | 425 +++++++++++++++++- Mohem/src/app/profile/models/basic.request.ts | 2 +- .../app/profile/service/profile.service.ts | 16 +- 9 files changed, 919 insertions(+), 103 deletions(-) diff --git a/Mohem/src/app/app.component.ts b/Mohem/src/app/app.component.ts index 1d7815fb..40b54e26 100644 --- a/Mohem/src/app/app.component.ts +++ b/Mohem/src/app/app.component.ts @@ -113,7 +113,6 @@ export class AppComponent implements OnInit { if (val instanceof NavigationEnd) { const lastIndex = val.urlAfterRedirects.lastIndexOf('/'); const currentPageName = val.urlAfterRedirects.substr(lastIndex + 1); - console.log(currentPageName + ' umarrrrrrrr'); this.setScreenNameAnalytics(currentPageName); } }); 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 f7fc2fdf..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']); } 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 5f52a665..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 @@ -9,9 +9,9 @@ - + Effective Date - 17-Mar-2017 + {{showEffectiveDate}}
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 ab5a7aa5..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 @@ -69,6 +69,8 @@ export class AddBasicDetailsComponent implements OnInit { public targetValue: any; public employeeBasicDetails: any = []; public mutualBasicDetailsArray: any = []; + public effectiveDate: string; + public showEffectiveDate: string; constructor( @@ -248,7 +250,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; for (let i = 0; i < this.eitColResponse.length; i++) { @@ -262,12 +264,15 @@ export class AddBasicDetailsComponent implements OnInit { 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") && this.eitColResponse[i].ObjectValuesList === null) { + 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) { @@ -278,7 +283,13 @@ export class AddBasicDetailsComponent implements OnInit { } } - varcharValue = elemVal; + 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, @@ -326,7 +337,28 @@ export class AddBasicDetailsComponent implements OnInit { } } - if (val) varcharValue = val; + 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, @@ -1177,7 +1209,6 @@ 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; // } } @@ -1188,9 +1219,7 @@ export class AddBasicDetailsComponent implements OnInit { 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; } @@ -1199,16 +1228,13 @@ export class AddBasicDetailsComponent implements OnInit { 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.replace(/\//g, '/'); - formatedDate = formatedDate.replace(/ 00:00:00/g, ''); + let formatedDate = date.slice(0,9); let newDate = formatedDate.split("/").reverse(); const tmp = newDate[2]; newDate[2] = newDate[1]; @@ -1220,22 +1246,23 @@ export class AddBasicDetailsComponent implements OnInit { public fillBasicDetailsStructure() { - console.log(this.eitResponse); - console.log(this.eitColResponse); + this.mutualBasicDetailsArray = this.mutualBasicDetailsArray.concat(this.eitResponse, this.eitColResponse); - console.log(this.mutualBasicDetailsArray); + for (let i = 0; i < this.employeeBasicDetails.length; i++) { let val: any; - if (this.employeeBasicDetails[i].VARCHAR2_VALUE) + 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); - this.employeeBasicDetails[i].DATE_VALUE - else if (this.employeeBasicDetails[i].NUMBER_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; + } + const elem = document.getElementById( this.employeeBasicDetails[i].APPLICATION_COLUMN_NAME ) as HTMLInputElement; if (elem) { if (val) { let feldDetails = this.mutualBasicDetailsArray.find( @@ -1339,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; @@ -1459,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, @@ -1661,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; @@ -1700,36 +1738,20 @@ 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(); } } public submitBasicDetailsTransaction() { - // let EITTransactionValues:any= []; - this.arrValues = this.getElementsValues(); let staticValues = this.getElementsStaticValues(); let allStatisDynamicValues = this.arrValues.concat(staticValues); + if (allStatisDynamicValues) { this.basicRequest = { P_SELECTED_EMPLOYEE_NUMBER: this.selEmp, @@ -1737,44 +1759,15 @@ export class AddBasicDetailsComponent implements OnInit { P_SELECTED_RESP_ID: this.respID, P_FUNCTION_NAME: this.selMenu.GetMenuEntriesList.FUNCTION_NAME, EITTransactionTBL: allStatisDynamicValues, - // P_EFFECTIVE_DATE: moment(this.effectiveDate).format('DD-MMM-YYYY'), - P_ACTION: this.targetValue === 'correct' ? 'CORRECT' : 'CHANGE' + P_ACTION_TYPE: this.targetValue === 'correct' ? 'CORRECT' : 'CHANGE' }; + console.log(this.basicRequest); - // this.eitService - // .validateEITTransaction(this.eitRequest) - // .subscribe((result: any) => { - // this.handleEITValidateTr(result); - // }); + this.profileService.submitBasicDetailsTransaction(this.basicRequest).subscribe((result: any) => { + this.handleBasicdetailsResult(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: [] }; - // } - // } + } 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/models/basic.request.ts b/Mohem/src/app/profile/models/basic.request.ts index f3471c75..68f183ec 100644 --- a/Mohem/src/app/profile/models/basic.request.ts +++ b/Mohem/src/app/profile/models/basic.request.ts @@ -8,5 +8,5 @@ export class BasicRequest { public P_SELECTED_RESP_ID: Number; // P_DESC_FLEX_CONTEXT_CODE: string; EITTransactionTBL: EitTransactionModel[]; - P_ACTION: string; + 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