From 3f12278312f10a11cb016c681a78d47a89575d38 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 29 Jun 2022 12:54:05 -0400 Subject: [PATCH] LP1840773 SCKO Angular Signed-off-by: Bill Erickson --- Open-ILS/src/eg2/src/app/scko/items.component.ts | 1 + Open-ILS/src/eg2/src/app/scko/scko.service.ts | 96 ++++++++++++++++++++++ .../src/eg2/src/app/scko/summary.component.html | 4 +- Open-ILS/src/eg2/src/app/scko/summary.component.ts | 2 - .../src/sql/Pg/upgrade/YYYY.data.scko-angular.sql | 37 +++++++++ 5 files changed, 136 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/scko/items.component.ts b/Open-ILS/src/eg2/src/app/scko/items.component.ts index bd759e84f8..9da559ea55 100644 --- a/Open-ILS/src/eg2/src/app/scko/items.component.ts +++ b/Open-ILS/src/eg2/src/app/scko/items.component.ts @@ -49,6 +49,7 @@ export class SckoItemsComponent implements OnInit { }); } + // TODO use scko versions isPrecat(copy: IdlObject): boolean { return Number(copy.id()) === -1; } diff --git a/Open-ILS/src/eg2/src/app/scko/scko.service.ts b/Open-ILS/src/eg2/src/app/scko/scko.service.ts index 13e2202470..619bb0062f 100644 --- a/Open-ILS/src/eg2/src/app/scko/scko.service.ts +++ b/Open-ILS/src/eg2/src/app/scko/scko.service.ts @@ -578,6 +578,102 @@ export class SckoService { return promise; } + + logoutPatron(receiptType: string): Promise { + + let promise; + + switch (receiptType) { + case 'email': + promise = this.emailReceipt() + break; + case 'print': + promise = this.printReceipt(); + break; + default: + promise = Promise.resolve(); + } + + return promise.then(_ => { + this.resetPatron(); + this.router.navigate(['/scko']); + }); + } + + emailReceipt(): Promise { + + const circIds = this.sessionCheckouts + .filter(c => Boolean(c.circ)).map(c => c.circ.id()); + + return this.net.request( + 'open-ils.circ', + 'open-ils.circ.checkout.batch_notify.session.atomic', + this.auth.token(), this.patronSummary.id, circIds + ).toPromise(); + } + + printReceipt(): Promise { + + return new Promise((resolve, reject) => { + + const sub = this.printer.printJobQueued$.subscribe(_ => { + sub.unsubscribe(); + // Give the print operation just a bit more time after + // the data is passed to the printer just to be safe. + setTimeout(() => resolve, 1000); + }); + + const data = this.sessionCheckouts.map(c => { + return { + checkout: c, + barcode: c.ctx.barcode, + circ: c.circ, + copy: c.circ ? c.circ.target_copy() : null, + title: this.getCircTitle(c.circ), + author: this.getCircAuthor(c.circ) + }; + }); + + + this.printer.print({ + templateName: 'scko_checkouts', + contextData: { + checkouts: data, + user: this.patronSummary.patron + }, + printContext: 'default' + }); + }); + } + + copyIsPrecat(copy: IdlObject): boolean { + return Number(copy.id()) === -1; + } + + circDisplayValue(circ: IdlObject, field: string): string { + if (!circ) { return ''; } + + const entry = + circ.target_copy().call_number().record().flat_display_entries() + .filter(e => e.name() === field)[0]; + + return entry ? entry.value() : ''; + } + + getCircTitle(circ: IdlObject): string { + if (!circ) { return ''; } + const copy = circ.target_copy(); + if (this.copyIsPrecat(copy)) { return copy.dummy_title(); } + return this.circDisplayValue(circ, 'title'); + } + + getCircAuthor(circ: IdlObject): string { + if (!circ) { return ''; } + const copy = circ.target_copy(); + if (this.copyIsPrecat(copy)) { return copy.dummy_author(); } + return this.circDisplayValue(circ, 'author'); + } + } diff --git a/Open-ILS/src/eg2/src/app/scko/summary.component.html b/Open-ILS/src/eg2/src/app/scko/summary.component.html index dd9cf2999e..f7329a04e3 100644 --- a/Open-ILS/src/eg2/src/app/scko/summary.component.html +++ b/Open-ILS/src/eg2/src/app/scko/summary.component.html @@ -3,12 +3,12 @@
- + - + diff --git a/Open-ILS/src/eg2/src/app/scko/summary.component.ts b/Open-ILS/src/eg2/src/app/scko/summary.component.ts index fa46b22ec0..3b434c6f37 100644 --- a/Open-ILS/src/eg2/src/app/scko/summary.component.ts +++ b/Open-ILS/src/eg2/src/app/scko/summary.component.ts @@ -23,7 +23,6 @@ export class SckoSummaryComponent implements OnInit { ) {} ngOnInit() { - this.scko.patronLoaded.subscribe(() => { if (this.canEmail()) { this.showEmailOption = true; @@ -33,7 +32,6 @@ export class SckoSummaryComponent implements OnInit { this.receiptType = 'print'; } }); - } canEmail(): boolean { diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.data.scko-angular.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.data.scko-angular.sql index 0fc704067d..a2dc616a3a 100644 --- a/Open-ILS/src/sql/Pg/upgrade/YYYY.data.scko-angular.sql +++ b/Open-ILS/src/sql/Pg/upgrade/YYYY.data.scko-angular.sql @@ -135,6 +135,43 @@ UPDATE config.print_template SET template = $TEMPLATE$
$TEMPLATE$ WHERE name = 'scko_fines'; +INSERT INTO config.print_template + (name, label, owner, active, locale, content_type, template) +VALUES ('scko_checkouts', 'Self-Checkout Checkouts', 1, TRUE, 'en-US', 'text/html', ''); + +UPDATE config.print_template SET template = $TEMPLATE$ +[%- + USE date; + SET user = template_data.user; + SET checkouts = template_data.checkouts; +-%] +
+ +
[% date.format(date.now, '%x %r') %]
+
+ + [% user.pref_family_name || user.family_name %], + [% user.pref_first_given_name || user.first_given_name %] + +
    + [% FOR checkout IN checkouts %] +
  1. +
    [% checkout.title %]
    +
    Barcode: [% checkout.barcode %]
    +
    Due Date: [% + IF checkout.circ; + date.format(helpers.format_date( + checkout.circ.due_date, staff_org_timezone), '%x %r') + END; + %] +
    +
  2. + [% END %] +
+
+$TEMPLATE$ WHERE name = 'scko_checkouts'; + + COMMIT; -- 2.11.0