Cash Reports
authorZavier Banks <zbanks@catalyte.io>
Tue, 14 Jan 2020 21:01:01 +0000 (21:01 +0000)
committerZavier Banks <zbanks@catalyte.io>
Tue, 14 Jan 2020 21:01:01 +0000 (21:01 +0000)
Currently porting over cash reports from dojo
to angular.

Signed-off-by: Zavier Banks <zbanks@catalyte.io>
Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html
Open-ILS/src/eg2/src/app/staff/admin/local/cash-reports/cash-reports.component.html
Open-ILS/src/eg2/src/app/staff/admin/local/cash-reports/cash-reports.component.ts
Open-ILS/src/eg2/src/app/staff/admin/local/cash-reports/routing.module.ts

index e051d37..cbcbe99 100644 (file)
@@ -15,8 +15,8 @@
       routerLink="/staff/admin/local/container/carousel_org_unit"></eg-link-table-link>
     <eg-link-table-link i18n-label label="Carousels"
       routerLink="/staff/admin/local/container/carousel"></eg-link-table-link>
-    <eg-link-table-link i18n-label label="Cash Reports" 
-      url="/eg/staff/admin/local/money/cash_reports"></eg-link-table-link>
+    <eg-link-table-link i18n-label label="Cash Reports"
+      routerLink="/staff/admin/local/money/cash_reports"></eg-link-table-link>
     <eg-link-table-link i18n-label label="Circulation Limit Sets" 
       url="/eg/staff/admin/local/config/circ_limit_set"></eg-link-table-link>
     <eg-link-table-link i18n-label label="Circulation Policies" 
index 49032c2..40af477 100644 (file)
@@ -1,5 +1,37 @@
-<eg-title i18n-prefix prefix="Cash Reports"></eg-title>\r
-<eg-staff-banner bannerText="Cash Reports" i18n-bannerText>\r
-</eg-staff-banner>\r
-<eg-date-select></eg-date-select>\r
-<eg-date-select></eg-date-select>\r
+<eg-title i18n-prefix prefix="Cash Reports"></eg-title>
+<eg-staff-banner bannerText="Cash Reports" i18n-bannerText>
+</eg-staff-banner>
+
+<div>
+    <div class="row">
+        <div class="input-group">
+            <div class="input-group-prepend">
+                <div class="input-group-text" i18n>Start Date</div> 
+                <eg-date-select (onChangeAsDate)="onStartDateChange($event)"></eg-date-select>
+            </div>
+        </div>
+        <div class="input-group">
+            <div class="input-group-prepend">
+                <div class="input-group-text" i18n>End Date</div> 
+                <eg-date-select (onChangeAsDate)="onEndDateChange($event)"></eg-date-select>
+            </div>
+        </div>
+    </div>
+    <div class="input-group">
+        <div class="input-group-prepend">
+            <div class="input-group-text" i18n>Org Select</div>
+            <eg-org-select (onChange)="onOrgChange($event)"></eg-org-select>
+        </div>
+    </div>
+</div>
+
+<eg-grid #deskPaymentgrid [idlClass]="deskIdlClass"
+  [dataSource]="deskPaymentDataSource"
+  [sortable]="true">
+</eg-grid>
+
+<eg-grid #userPaymentgrid [idlClass]="userIdlClass"
+  [dataSource]="userPaymentDataSource"
+  [sortable]="true">
+</eg-grid>
+
index 0377d0a..c7ee206 100644 (file)
@@ -1,12 +1,75 @@
-import {Component, OnInit, Input, ViewChild} from '@angular/core';\r
-\r
-@Component({\r
-    templateUrl: './cash-reports.component.html'\r
-})\r
-\r
-export class CashReportsComponent implements OnInit {\r
-\r
-    ngOnInit() { }\r
-\r
-}\r
-\r
+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);
+        });
+    }
+}
index 09ee514..65f7620 100644 (file)
@@ -1,15 +1,15 @@
-import {NgModule} from '@angular/core';\r
-import {RouterModule, Routes} from '@angular/router';\r
-import {CashReportsComponent} from './cash-reports.component';\r
-\r
-const routes: Routes = [{\r
-    path: '',\r
-    component: CashReportsComponent\r
-}];\r
-\r
-@NgModule({\r
-  imports: [RouterModule.forChild(routes)],\r
-  exports: [RouterModule]\r
-})\r
-\r
+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