From df7c53059ee50ef1972782e48a6efb6c19f93370 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Sun, 19 Jun 2022 11:21:11 +0300 Subject: [PATCH] concorrent report changes --- Mohem/src/app/app.component.ts | 3 +- .../authentication/authentication.service.ts | 4 +- .../services/common/common.service.ts | 4 + .../app/itemforsale/home/home.component.ts | 9 - .../add-basic-details.component.ts | 180 +++++++-------- Mohem/src/app/reports/reports.module.ts | 7 +- .../transactions/transactions.component.html | 69 ++++++ .../transactions/transactions.component.scss | 213 ++++++++++++++++++ .../transactions.component.spec.ts | 27 +++ .../transactions/transactions.component.ts | 126 +++++++++++ 10 files changed, 539 insertions(+), 103 deletions(-) create mode 100644 Mohem/src/app/reports/transactions/transactions.component.html create mode 100644 Mohem/src/app/reports/transactions/transactions.component.scss create mode 100644 Mohem/src/app/reports/transactions/transactions.component.spec.ts create mode 100644 Mohem/src/app/reports/transactions/transactions.component.ts diff --git a/Mohem/src/app/app.component.ts b/Mohem/src/app/app.component.ts index 676501d7..aee9f1a2 100644 --- a/Mohem/src/app/app.component.ts +++ b/Mohem/src/app/app.component.ts @@ -357,7 +357,8 @@ export class AppComponent implements OnInit { } oepnMyRequest(menu) { this.cs.sharedService.setSharedData(menu, MenuResponse.SELECTED_MENU); - this.cs.openConcurrentReport(); + // this.cs.openConcurrentReport(); + this.cs.openConcurrentTransactionsHome(); this.menu.toggle(); } oepnTransaction() { diff --git a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts index 7c6bdb82..1e613563 100644 --- a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts +++ b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts @@ -145,7 +145,7 @@ export class AuthenticationService { } else { mobileType = 'android'; } - request.VersionID = 3.5; + request.VersionID = 3.6; request.Channel = 31; request.LanguageID = TranslatorService.getCurrentLanguageCode(); request.MobileType = mobileType; @@ -495,7 +495,7 @@ export class AuthenticationService { return this.con.post(AuthenticationService.activationCodeURL, request, onError, errorLabel); } - public checkSMS(request: SMSCheckRequest, onError: any, errorLabel: string, fromSMS = false ) + public checkSMS(request: SMSCheckRequest, onError: any, errorLabel: string, fromSMS = false) : Observable { this.setPublicFields(request); return this.con.post(AuthenticationService.smsCheck, request, onError, errorLabel, fromSMS); 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 4bfffd47..d120bee3 100644 --- a/Mohem/src/app/hmg-common/services/common/common.service.ts +++ b/Mohem/src/app/hmg-common/services/common/common.service.ts @@ -1358,6 +1358,10 @@ export class CommonService { this.nav.navigateForward(['/reports/transaction-list']); } + public openConcurrentTransactionsHome() { + + this.nav.navigateForward(['/reports/transactions']); + } public openTermination() { this.nav.navigateForward(['/termination/termination-form']); diff --git a/Mohem/src/app/itemforsale/home/home.component.ts b/Mohem/src/app/itemforsale/home/home.component.ts index bdff62ff..10fc21bf 100644 --- a/Mohem/src/app/itemforsale/home/home.component.ts +++ b/Mohem/src/app/itemforsale/home/home.component.ts @@ -301,15 +301,6 @@ export class HomeComponent implements OnInit { return { AttachmentID: this.indexLastObj, FileName: res.name, Base64Data: res.data.split(",")[1], ContentType: 'image/' + attachType }; }); - - - - - - - - - } catch (e) { } } } 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 2e1f8ea0..95ad98d7 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 @@ -49,7 +49,7 @@ export class AddBasicDetailsComponent implements OnInit { private hiddenInput: HiddenInput; private eitResponse: any; private eitColResponse: any; - + private eitVALSettoCall: any = []; private comtransNo: number = 0; getPassMnuEntryObj: MenuEntry; @@ -65,7 +65,7 @@ export class AddBasicDetailsComponent implements OnInit { isResubmit: boolean = false; private updatedValues: any = []; addEITData: any; - direction:string; + direction: string; public targetValue: any; public employeeBasicDetails: any = []; public mutualBasicDetailsArray: any = []; @@ -135,7 +135,7 @@ export class AddBasicDetailsComponent implements OnInit { } } - ngOnInit() {} + ngOnInit() { } ngAfterViewInit() { this.getEitDffStructure(); @@ -171,7 +171,7 @@ export class AddBasicDetailsComponent implements OnInit { this.drawEitFieldsStatic(result.GetBasicDetColsStructureList); } } - + public handleBasicDffStructureResult(result) { if (result.GetBasicDetDffStructureList != null) { this.getColumnStructure(); @@ -188,59 +188,59 @@ export class AddBasicDetailsComponent implements OnInit { 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 - ); - + //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(); } @@ -251,7 +251,7 @@ export class AddBasicDetailsComponent implements OnInit { let numbervalue: any = 0; let dateValue: any = null; let transNo: number = 1; - let textValue : any; + let textValue: any; for (let i = 0; i < this.eitColResponse.length; i++) { varcharValue = null; @@ -260,10 +260,10 @@ export class AddBasicDetailsComponent implements OnInit { 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 : ''; + 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') { @@ -272,7 +272,7 @@ export class AddBasicDetailsComponent implements OnInit { } 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) { @@ -301,11 +301,11 @@ export class AddBasicDetailsComponent implements OnInit { } 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; - + 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"); @@ -323,7 +323,7 @@ export class AddBasicDetailsComponent implements OnInit { DATE_VALUE: dateValue }); } - } else { + } 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 : ''; @@ -815,8 +815,8 @@ export class AddBasicDetailsComponent implements OnInit { let obj = this.handleDefaultValueResult(result); let val = obj.value; let text = obj.text; - if (val==null){val="";} - if (text==null){text="";} + if (val == null) { val = ""; } + if (text == null) { text = ""; } if (isStandardDate) { console.log("isStandardDate"); elem.value = this.cs.reverseFormatDate(val); @@ -834,7 +834,7 @@ export class AddBasicDetailsComponent implements OnInit { if (val) { elem.dataset.dtvalue = val; elem.innerHTML = val; - elem.value=val; + elem.value = val; } else { elem.dataset.dtvalue = ""; elem.innerHTML = ""; @@ -843,11 +843,11 @@ export class AddBasicDetailsComponent implements OnInit { if (isSelectElement) { let elem = this.getSelectElementByName(segmentName); elem = document.getElementById(elem), - elem.value = val; + elem.value = val; } else { - elem.value = val; - elem.innerText = text; - elem.setAttribute("value", val); + elem.value = val; + elem.innerText = text; + elem.setAttribute("value", val); } } if (isHidden || isReadOnlyList) { @@ -1234,7 +1234,7 @@ export class AddBasicDetailsComponent implements OnInit { } public customiseDate(date: any) { - let formatedDate = date.slice(0,9); + let formatedDate = date.slice(0, 9); let newDate = formatedDate.split("/").reverse(); const tmp = newDate[2]; newDate[2] = newDate[1]; @@ -1248,7 +1248,7 @@ export class AddBasicDetailsComponent implements OnInit { 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) { @@ -1256,13 +1256,13 @@ export class AddBasicDetailsComponent implements OnInit { } 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.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( @@ -1367,7 +1367,7 @@ export class AddBasicDetailsComponent implements OnInit { let numbervalue: any = 0; let dateValue: any = null; let transNo: number = 1; - let textValue : any; + let textValue: any; // if(this.ExtraObj.transactionNo) // transNo=this.ExtraObj.transactionNo; for (let i = 0; i < this.eitResponse.length; i++) { @@ -1413,11 +1413,11 @@ export class AddBasicDetailsComponent implements OnInit { this.eitResponse[i].DISPLAY_FLAG != "N" ) { //time - if(elemVal.length>5){ - elemVal = elemVal.substring(11, 16); - }else{ - elemVal = elemVal; - } + if (elemVal.length > 5) { + elemVal = elemVal.substring(11, 16); + } else { + elemVal = elemVal; + } } if (this.eitResponse[i].REQUIRED_FLAG == "Y" && !elemVal) { elem.classList.add("requiredClassElm"); @@ -1426,11 +1426,11 @@ export class AddBasicDetailsComponent implements OnInit { } else { elem.classList.remove("requiredClassElm"); } - // if (elemVal != 'null'){ - varcharValue = elemVal; + // if (elemVal != 'null'){ + varcharValue = elemVal; //} else{ - // elemVal = null; - // } + // elemVal = null; + // } valuseArr.push({ TRANSACTION_NUMBER: transNo, NAME: this.eitResponse[i].APPLICATION_COLUMN_NAME, @@ -1759,15 +1759,15 @@ export class AddBasicDetailsComponent implements OnInit { P_SELECTED_RESP_ID: this.respID, P_FUNCTION_NAME: this.selMenu.GetMenuEntriesList.FUNCTION_NAME, EITTransactionTBL: allStatisDynamicValues, - P_ACTION_TYPE: this.targetValue === 'correct' ? 'CORRECT' : 'CHANGE' + P_ACTION_TYPE: this.targetValue === 'correct' ? 'CORRECT' : 'CHANGE' }; console.log(this.basicRequest); this.profileService.submitBasicDetailsTransaction(this.basicRequest).subscribe((result: any) => { - this.handleBasicdetailsResult(result); + this.handleBasicdetailsResult(result); }); } } - + } diff --git a/Mohem/src/app/reports/reports.module.ts b/Mohem/src/app/reports/reports.module.ts index 0fc1953d..789a61cd 100644 --- a/Mohem/src/app/reports/reports.module.ts +++ b/Mohem/src/app/reports/reports.module.ts @@ -10,6 +10,7 @@ import { ConcurrentReportComponent } from './concurrent-report/concurrent-report import { ReportServiceService } from './report-service.service'; import { HmgCommonModule } from '../hmg-common/hmg-common.module'; import { TransactionListComponent } from './transaction-list/transaction-list.component'; +import { TransactionsComponent } from './transactions/transactions.component'; const routes: Routes = [ @@ -25,6 +26,10 @@ const routes: Routes = [ path: 'transaction-list', component: TransactionListComponent }, + { + path: 'transactions', + component: TransactionsComponent + }, ], } ]; @@ -37,7 +42,7 @@ const routes: Routes = [ RouterModule.forChild(routes), HmgCommonModule ], - declarations: [ReportsPage, ConcurrentReportComponent, TransactionListComponent], + declarations: [ReportsPage, ConcurrentReportComponent, TransactionListComponent, TransactionsComponent], providers: [ReportServiceService] }) export class ReportsPageModule { } diff --git a/Mohem/src/app/reports/transactions/transactions.component.html b/Mohem/src/app/reports/transactions/transactions.component.html new file mode 100644 index 00000000..dd843220 --- /dev/null +++ b/Mohem/src/app/reports/transactions/transactions.component.html @@ -0,0 +1,69 @@ + +
+ + + +
+
+
+ + + +
+ + {{ 'worklist,template-name' | translate}} + + + {{ program.USER_CONCURRENT_PROGRAM_NAME}} + + +
+ +
{{getDate(transaction.REQUEST_DATE)}}
+ + +
+

{{'transaction, request-id' | translate}}

+

+ {{transaction.REQUEST_ID}} +

+
+

{{'transaction, phase' | translate}}

+

{{transaction.CCP_PHASE}}

+
+ + +
+

{{'transaction,program-name' | translate}}

+

{{transaction.CONCURRENT_PROGRAM_NAME}}

+
+
+ + +
+

{{'transaction,output' | translate}}

+

+

+
+ +
+
+ +
+
+ + + +

{{'general, noData' | translate}}

+
+
+ +
+ +
+ + {{'vacation-rule, create-request' | translate}} +
+
diff --git a/Mohem/src/app/reports/transactions/transactions.component.scss b/Mohem/src/app/reports/transactions/transactions.component.scss new file mode 100644 index 00000000..378cb377 --- /dev/null +++ b/Mohem/src/app/reports/transactions/transactions.component.scss @@ -0,0 +1,213 @@ +.display-created { + display: inline-block; + margin: 2px; + color: #000; +} + +#containerDiv { + margin-top: 20px; +} + +.padding { + padding-left: 5px; + padding-right: 5px; +} + +.bold { + font-weight: bold; + font-size: 16px; +} + +.color-black { + color: #000; +} + +.date { + position: absolute; + font-size: 14px; + padding: 10px; + right: 0; + width: 100px; + color: #969696; +} + +.date_ar { + position: absolute; + font-size: 14px; + padding: 10px; + left: 0; + width: 100px; + color: #969696; +} + +.transaction-list { + margin-top: 20px; +} + +.date-container { + margin: 0px 20px; +} + +.label { + font-size: 16px; + // margin-left: 15px; + color: #a2a5a6 !important; + display: block; + overflow: hidden; + -webkit-box-flex: 1; + -webkit-flex: 1; + -ms-flex: 1; + flex: 1; + /* font-size: inherit; */ + // text-overflow: ellipsis; + // white-space: nowrap; + white-space: normal; + // padding-top: 10px; + padding: 5px 0px; + padding-left: 10px !important; + margin: 10px auto; + + :root[dir="ltr"] { + font-family: var(--fontFamilySemiBoldEN) !important; + } + + :root[dir="rtl"] { + font-family: var(--fontFamilyIOSAR) !important; + font-weight: bold; + } + + +} + +.Field-en { + border-radius: 30px; + border: 1px solid #a2a5a6 !important; + margin-bottom: 15px; + padding-left: 20px !important; + padding-top: 6px !important; + color: #999999 !important; +} + +.Field-ar { + border-radius: 30px; + border: 1px solid #a2a5a6 !important; + margin-bottom: 20px; + padding-right: 20px !important; + padding-top: 6px !important; + color: #999999 !important; +} + +select { + width: 300px !important; + border: none !important; +} + +.padding_date { + padding-left: 5px !important; +} + +.date-icon { + font-size: 20px; + left: -1px; + position: relative; + top: 2px; +} + +ion-card { + padding: 10px; + border-radius: 11px; + box-shadow: 0px 1px 2px 1px #ccc; +} + +.display-inline { + display: inline-block; + +} + +.red { + color: #CA3332; + font-weight: 600; + margin: 0px 5px; + overflow: hidden; + width: 90%; + white-space: nowrap; + text-overflow: ellipsis; +} + +.inline-display { + display: inline-block; + font-weight: 600; + padding-left: 8px; +} + +.download { + font-size: 26px; + margin: 0px 10px; + position: relative; + top: 5px; + color: #CA3332; +} + +.refresh { + font-size: 22px; + margin: 0px 10px; + position: relative; + top: 5px; + color: #CA3332; +} + +.disabled-icon { + pointer-events: none; + opacity: .5; +} + +.output-container { + position: relative; + bottom: 10px; +} + +@media screen and (min-width: 300px) { + .CreateBtn { + --background: var(--newgreen) !important; + background: var(--newgreen) !important; + white-space: normal; + color: var(--light); + text-transform: capitalize; + min-height: 1.0cm; + --border-radius: 7px !important; + border-radius: 7px !important; + --min-height: 1.6cm !important; + width: 315px; + font-family: var(--fontFamilyPoppins-SemiBold, inherit); + } +} + +@media screen and (min-width: 1px) and (max-width:290px) { + .CreateBtn { + --background: var(--newgreen) !important; + background: var(--newgreen) !important; + white-space: normal; + color: var(--light); + text-transform: capitalize; + min-height: 1.0cm; + --border-radius: 7px !important; + border-radius: 7px !important; + --min-height: 1.6cm !important; + width: 257px; + font-family: var(--fontFamilyPoppins-SemiBold, inherit); + } +} + +.footer { + padding: 15px 0px; + background-color: var(--light) !important; + border: 0px !important; + box-shadow: none !important; + -webkit-box-shadow: none; +} + +.Btn { + margin: auto; + text-align: center; + display: block; +} \ No newline at end of file diff --git a/Mohem/src/app/reports/transactions/transactions.component.spec.ts b/Mohem/src/app/reports/transactions/transactions.component.spec.ts new file mode 100644 index 00000000..38769453 --- /dev/null +++ b/Mohem/src/app/reports/transactions/transactions.component.spec.ts @@ -0,0 +1,27 @@ +import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TransactionsComponent } from './transactions.component'; + +describe('TransactionsComponent', () => { + let component: TransactionsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ TransactionsComponent ], + schemas: [CUSTOM_ELEMENTS_SCHEMA], + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(TransactionsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Mohem/src/app/reports/transactions/transactions.component.ts b/Mohem/src/app/reports/transactions/transactions.component.ts new file mode 100644 index 00000000..b282f815 --- /dev/null +++ b/Mohem/src/app/reports/transactions/transactions.component.ts @@ -0,0 +1,126 @@ +import { Component, ElementRef, OnInit } from '@angular/core'; +import { FileOpener } from '@ionic-native/file-opener/ngx'; +import { File } from '@ionic-native/file/ngx'; +import { Platform } from '@ionic/angular'; +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 { ReportServiceService } from '../report-service.service'; + +@Component({ + selector: 'app-transactions', + templateUrl: './transactions.component.html', + styleUrls: ['./transactions.component.scss'], +}) +export class TransactionsComponent implements OnInit { + transactionList: any = []; + selectedMenu: any; + template: any; + direction: any; + programList: any = []; + + constructor(public cs: CommonService, private elementRef: ElementRef, public reports: ReportServiceService, public ts: TranslatorService, private platform: Platform, private file: File, private opener: FileOpener, + ) { } + + ngOnInit() { + + this.selectedMenu = this.cs.sharedService.getSharedData(MenuResponse.SELECTED_MENU, false); + // this.transactionList = this.cs.sharedService.getSharedData(ReportServiceService.TRANSACTION_LIST, false); + //this.template = this.cs.sharedService.getSharedData(ReportServiceService.TEMPLATE, false); + this.direction = TranslatorService.getCurrentDirection(); + this.getConcurrentProgram(); + } + getDate(date) { + return this.cs.evaluteDate(date); + } + getCppOutput(transaction) { + var request: any = { + P_REQUEST_ID: transaction['REQUEST_ID'] + }; + this.cs.startLoading(); + this.reports.getCppOutput(request, {}, this.ts.trPK('general', 'retry')).subscribe((result: any) => { + this.saveAndOpenPdf(result.GetCcpOutputList['P_OUTPUT_FILE'], 'report.pdf'); + + console.log(result); + this.cs.stopLoading(); + + }); + } + // saveAndOpenPdf(pdf: string, filename: string) { + + // const linkSource = `data:application/pdf;base64,${pdf}`; + // const downloadLink = document.createElement("a"); + // const fileName = "report.pdf"; + // downloadLink.href = linkSource; + // downloadLink.download = fileName; + // downloadLink.click(); + + // } + + saveAndOpenPdf(pdf: string, filename: string) { + const writeDirectory = this.platform.is('ios') ? this.file.dataDirectory : this.file.externalDataDirectory; + this.file.writeFile(writeDirectory, filename, this.convertBase64ToBlob(pdf, 'data:application/pdf;base64'), { replace: true }) + .then(() => { + this.opener.open(writeDirectory + filename, 'application/pdf') + .catch(() => { + console.log('Error opening pdf file'); + }); + }) + .catch(() => { + console.error('Error writing pdf file'); + }); + } + + convertBase64ToBlob(b64Data, contentType): Blob { + contentType = contentType || ''; + const sliceSize = 512; + b64Data = b64Data.replace(/^[^,]+,/, ''); + b64Data = b64Data.replace(/\s/g, ''); + const byteCharacters = window.atob(b64Data); + const byteArrays = []; + for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) { + const slice = byteCharacters.slice(offset, offset + sliceSize); + const byteNumbers = new Array(slice.length); + for (let i = 0; i < slice.length; i++) { + byteNumbers[i] = slice.charCodeAt(i); + } + const byteArray = new Uint8Array(byteNumbers); + byteArrays.push(byteArray); + } + return new Blob(byteArrays, { type: contentType }); + } + refresh() { + // var request: any = { + // P_REQUEST_ID: transaction['REQUEST_ID'] + // }; + this.cs.startLoading(); + var request: any = {}; + request.P_MENU_TYPE = this.selectedMenu.MENU_TYPE; + request.P_SELECTED_RESP_ID = -999; + request.P_FUNCTION_NAME = this.selectedMenu.FUNCTION_NAME; + request.P_DESC_FLEX_NAME = this.template.CONCURRENT_PROGRAM_NAME; + + this.reports.getTransaction(request, {}, this.ts.trPK('general', 'retry')).subscribe((result: any) => { + this.cs.stopLoading(); + this.transactionList = result['GetCcpTransactionsList_New']; + }); + } + getConcurrentProgram() { + this.cs.startLoading(); + this.reports.getConcurrentProgram({ + P_REQUEST_GROUP_ID: this.selectedMenu.REQUEST_GROUP_ID + }, () => { }, this.ts.trPK('general', 'retry')).subscribe((response) => { + this.cs.stopLoading(); + this.programList = response.GetConcurrentProgramsList; + + }) + } + selectTemplates() { + // this.elementRef + // .nativeElement.querySelectorAll('#containerDiv')[0].innerHTML = ''; + this.refresh(); + } + createTransaction() { + this.cs.openConcurrentReport(); + } +}