From c3d2c0c84f02079b398f1a80f8d72a5c306bcb34 Mon Sep 17 00:00:00 2001 From: Zavier Banks Date: Tue, 14 Jan 2020 21:01:01 +0000 Subject: [PATCH] Cash Reports Currently porting over cash reports from dojo to angular. Signed-off-by: Zavier Banks --- .../admin/local/admin-local-splash.component.html | 4 +- .../local/cash-reports/cash-reports.component.html | 42 +++++++++-- .../local/cash-reports/cash-reports.component.ts | 87 +++++++++++++++++++--- .../admin/local/cash-reports/routing.module.ts | 28 +++---- 4 files changed, 128 insertions(+), 33 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html index e051d37c42..cbcbe996d7 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html @@ -15,8 +15,8 @@ routerLink="/staff/admin/local/container/carousel_org_unit"> - + - - - - + + + + +
+
+
+
+
Start Date
+ +
+
+
+
+
End Date
+ +
+
+
+
+
+
Org Select
+ +
+
+
+ + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/cash-reports/cash-reports.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/cash-reports/cash-reports.component.ts index 0377d0aada..c7ee206bf5 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/cash-reports/cash-reports.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/cash-reports/cash-reports.component.ts @@ -1,12 +1,75 @@ -import {Component, OnInit, Input, ViewChild} from '@angular/core'; - -@Component({ - templateUrl: './cash-reports.component.html' -}) - -export class CashReportsComponent implements OnInit { - - ngOnInit() { } - -} - +import {Pager} from '@eg/share/util/pager'; +import {Component, OnInit, Input, ViewChild} from '@angular/core'; +import {GridComponent} from '@eg/share/grid/grid.component'; +import {GridDataSource, GridColumn, GridRowFlairEntry} from '@eg/share/grid/grid'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {NetService} from '@eg/core/net.service'; +import {AuthService} from '@eg/core/auth.service'; + +@Component({ + templateUrl: './cash-reports.component.html' +}) + +export class CashReportsComponent implements OnInit { + initDone = false; + deskPaymentDataSource: GridDataSource = new GridDataSource(); + userPaymentDataSource: GridDataSource = new GridDataSource(); + deskIdlClass = 'mwps'; + userIdlClass = 'mups'; + selectedOrg: any; + startDate: any; + endDate: any; + + // Default sort field, used when no grid sorting is applied. + @Input() sortField: string; + + @ViewChild('deskPaymentgrid', { static: true }) deskPaymentgrid: GridComponent; + @ViewChild('userPaymentgrid', { static: true }) userPaymentgrid: GridComponent; + + constructor( + private pcrud: PcrudService, + private net: NetService, + private auth: AuthService){} + + ngOnInit() {} + + findGridData(idlClass, dataSource) { + this[dataSource].getRows = (pager: Pager, sort: any[]) => { + const orderBy: any = {}; + if (sort.length) { + // Sort specified from grid + orderBy[idlClass] = sort[0].name + ' ' + sort[0].dir; + } else if (this.sortField) { + // Default sort field + orderBy[idlClass] = this.sortField; + }; + const searchOps = { + offset: pager.offset, + limit: pager.limit, + order_by: orderBy + }; + return this.pcrud.retrieveAll(idlClass, searchOps, {fleshSelectors: true}); + }; + } + + onStartDateChange(date) { + this.startDate = date; + } + + onEndDateChange(date) { + this.endDate = date; + } + + onOrgChange(org) { + this.selectedOrg = org; + console.log(this.selectedOrg) + this.findGridData(this.deskIdlClass,'deskPaymentDataSource'); + this.findGridData(this.userIdlClass,'userPaymentDataSource'); + this.net.request('open-ils.circ', 'open-ils.circ.money.org_unit.user_payments', this.auth.token(), this.selectedOrg.id(), this.startDate, this.endDate).subscribe(result=>{ + console.log(result); + }); + this.net.request('open-ils.circ', 'open-ils.circ.money.org_unit.user_payments', this.auth.token(), this.selectedOrg.id(), this.startDate, this.endDate).subscribe(result=>{ + console.log(result); + }); + } +} diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/cash-reports/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/cash-reports/routing.module.ts index 09ee5147d2..65f7620c8c 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/cash-reports/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/cash-reports/routing.module.ts @@ -1,15 +1,15 @@ -import {NgModule} from '@angular/core'; -import {RouterModule, Routes} from '@angular/router'; -import {CashReportsComponent} from './cash-reports.component'; - -const routes: Routes = [{ - path: '', - component: CashReportsComponent -}]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) - +import {NgModule} from '@angular/core'; +import {RouterModule, Routes} from '@angular/router'; +import {CashReportsComponent} from './cash-reports.component'; + +const routes: Routes = [{ + path: '', + component: CashReportsComponent +}]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) + export class CashReportsRoutingModule {} \ No newline at end of file -- 2.11.0