LP1840773 SCKO Angular
authorBill Erickson <berickxx@gmail.com>
Thu, 23 Jun 2022 21:02:42 +0000 (17:02 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 23 Jun 2022 21:02:42 +0000 (17:02 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/scko/holds.component.html
Open-ILS/src/eg2/src/app/scko/holds.component.ts
Open-ILS/src/eg2/src/app/scko/items.component.html
Open-ILS/src/eg2/src/app/scko/items.component.ts
Open-ILS/src/eg2/src/app/scko/scko.service.ts
Open-ILS/src/eg2/src/app/share/print/print.service.ts
Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/YYYY.data.scko-angular.sql [new file with mode: 0644]

index 0834559..ff10e9b 100644 (file)
@@ -1,3 +1,9 @@
+<div class="d-flex">
+  <div class="flex-1"></div>
+  <div>
+    <button class="btn btn-outline-dark" (click)="printList()" i18n>Print List</button>
+  </div>
+</div>
 <div id='oils-selfck-circ-table-div'>
   <table id='oils-selfck-circ-table' class='oils-selfck-item-table'>
     <thead>
index 81ae44f..131cf73 100644 (file)
@@ -7,6 +7,7 @@ import {NetService} from '@eg/core/net.service';
 import {IdlObject} from '@eg/core/idl.service';
 import {SckoService} from './scko.service';
 import {ServerStoreService} from '@eg/core/server-store.service';
+import {PrintService} from '@eg/share/print/print.service';
 
 @Component({
   templateUrl: 'holds.component.html'
@@ -22,6 +23,7 @@ export class SckoHoldsComponent implements OnInit {
         private net: NetService,
         private auth: AuthService,
         private pcrud: PcrudService,
+        private printer: PrintService,
         public  scko: SckoService
     ) {}
 
@@ -60,6 +62,17 @@ export class SckoHoldsComponent implements OnInit {
             this.holds.push(holdData);
         });
     }
+
+    printList() {
+        this.printer.print({
+            templateName: 'scko_holds',
+            contextData: {
+              holds: this.holds,
+              user: this.scko.patronSummary.patron
+            },
+            printContext: 'default'
+        });
+    }
 }
 
 
index e861623..28daf25 100644 (file)
@@ -1,3 +1,9 @@
+<div class="d-flex">
+  <div class="flex-1"></div>
+  <div>
+    <button class="btn btn-outline-dark" (click)="printList()" i18n>Print List</button>
+  </div>
+</div>
 <div id='oils-selfck-circ-table-div'>
   <table id='oils-selfck-circ-table' class='oils-selfck-item-table'>
     <thead>
index 9f2bf71..e9ceba1 100644 (file)
@@ -7,6 +7,7 @@ import {NetService} from '@eg/core/net.service';
 import {IdlObject} from '@eg/core/idl.service';
 import {SckoService} from './scko.service';
 import {ServerStoreService} from '@eg/core/server-store.service';
+import {PrintService} from '@eg/share/print/print.service';
 
 const CIRC_FLESH_DEPTH = 4;
 const CIRC_FLESH_FIELDS = {
@@ -30,6 +31,7 @@ export class SckoItemsComponent implements OnInit {
         private net: NetService,
         private auth: AuthService,
         private pcrud: PcrudService,
+        private printer: PrintService,
         public  scko: SckoService
     ) {}
 
@@ -87,5 +89,25 @@ export class SckoItemsComponent implements OnInit {
         if (this.isPrecat(copy)) { return copy.dummy_author(); }
         return this.displayValue(circ, 'author');
     }
+
+    printList() {
+
+        const data = this.circs.map(c => {
+            return {
+                circ: c,
+                copy: c.target_copy(),
+                title: this.getTitle(c),
+                author: this.getAuthor(c)
+            };
+        });
+
+        this.printer.print({
+            templateName: 'scko_items_out',
+            contextData: {checkouts: data},
+            printContext: 'default'
+        });
+    }
 }
 
+
+
index 9927903..2268edf 100644 (file)
@@ -8,6 +8,7 @@ import {IdlService, IdlObject} from '@eg/core/idl.service';
 import {StoreService} from '@eg/core/store.service';
 import {PatronService, PatronSummary, PatronStats} from '@eg/staff/share/patron/patron.service';
 import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
+import {PrintService} from '@eg/share/print/print.service';
 
 @Injectable({providedIn: 'root'})
 export class SckoService {
@@ -33,6 +34,7 @@ export class SckoService {
         private net: NetService,
         private evt: EventService,
         public auth: AuthService,
+        private printer: PrintService,
         private patrons: PatronService,
     ) {}
 
@@ -191,6 +193,17 @@ export class SckoService {
             this.patronSummary.stats.checkouts.overdue +
             this.patronSummary.stats.checkouts.long_overdue;
     }
+
+
+    /*
+    logout(receiptType:
+    this.printer.print({
+    templateName: 'bills_current',
+    contextData: {xacts: rows},
+    printContext: 'default'
+    });
+    */
+
 }
 
 
index 5723a4c..e2d7a97 100644 (file)
@@ -99,6 +99,9 @@ export class PrintService {
                     } else if (this.status === 404) {
                         console.error('No active template found: ', printReq);
                         reject({notFound: true});
+                    } else {
+                        console.error(
+                            "Print template generator returned status: " + this.status);
                     }
                     reject({});
                 }
index dab85c0..aff7035 100644 (file)
@@ -57,6 +57,10 @@ sub personality {
         # Instance-specific personality
 
         if ($app) {
+            # Reset everything in case this editor instance was
+            # previously used as a different personality.
+            delete $self->{session};
+            $self->{app} = $app;
             $self->{personality} = $app;
             init();
         }
index d678fb3..a5931ef 100644 (file)
@@ -52,9 +52,10 @@ sub handler {
 
     # Requires staff login
     return Apache2::Const::FORBIDDEN 
-        unless $e->checkauth && $e->requestor->wsid;
+        unless $e->checkauth && $e->allowed('STAFF_LOGIN');
 
     # Let pcrud handle the authz
+    #$e->{app} = 'open-ils.pcrud';
     $e->personality('open-ils.pcrud');
 
     my $tmpl_owner = $cgi->param('template_owner') || $e->requestor->ws_ou;
index efcf20a..9d22cd1 100644 (file)
             SET udata =  user_data.$idx
         -%]
         <li>
-            <div>Title: [% udata.item_title %]</div>
+          <table>
+            <tr>
+              <td>Title:</td>
+              <td>[% hold.title %]</td>
+            </tr>
+            <tr>
+              <td>author:</td>
+              <td>[% hold.author %]</td>
+            </tr>
+
             <div>Author: [% udata.item_author %]</div>
             <div>Pickup Location: [% udata.pickup_lib %]</b></div>
             <div>Status: 
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
new file mode 100644 (file)
index 0000000..c92f1ef
--- /dev/null
@@ -0,0 +1,93 @@
+
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version); 
+
+INSERT INTO config.print_template 
+    (name, label, owner, active, locale, content_type, template)
+VALUES ('scko_items_out', 'Self-Checkout Items Out', 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;
+-%]
+<div>
+  <style> li { padding: 8px; margin 5px; }</style>
+  <div>[% date.format(date.now, '%x %r') %]</div>
+  <br/>
+
+  [% user.pref_family_name || user.family_name %], 
+  [% user.pref_first_given_name || user.first_given_name %]
+
+  <ol>
+  [% FOR checkout IN checkouts %]
+    <li>
+      <div>[% checkout.title %]</div>
+      <div>Barcode: [% checkout.copy.barcode %]</div>
+      <div>Due Date: [% 
+        date.format(helpers.format_date(
+            checkout.circ.due_date, staff_org_timezone), '%x %r') 
+      %]
+      </div>
+    </li>
+  [% END %]
+  </ol>
+</div>
+$TEMPLATE$ WHERE name = 'scko_items_out';
+
+INSERT INTO config.print_template 
+    (name, label, owner, active, locale, content_type, template)
+VALUES ('scko_holds', 'Self-Checkout Holds', 1, TRUE, 'en-US', 'text/html', '');
+
+UPDATE config.print_template SET template = $TEMPLATE$
+[%- 
+    USE date;
+    SET user = template_data.user;
+    SET holds = template_data.holds;
+-%]
+<div>
+  <style> li { padding: 8px; margin 5px; }</style>
+  <div>[% date.format(date.now, '%x %r') %]</div>
+  <br/>
+
+  [% user.pref_family_name || user.family_name %], 
+  [% user.pref_first_given_name || user.first_given_name %]
+
+  <ol>
+  [% FOR hold IN holds %]
+    <li>
+      <table>
+        <tr>
+          <td>Title:</td>
+          <td>[% hold.title %]</td>
+        </tr>
+        <tr>
+          <td>Author:</td>
+          <td>[% hold.author %]</td>
+        </tr>
+        <tr>
+          <td>Pickup Location:</td>
+          <td>[% helpers.get_org_unit(hold.pickup_lib).name %]</td>
+        </tr>
+        <tr>
+          <td>Status:</td>
+          <td>
+            [%- IF hold.ready -%]
+                Ready for pickup
+            [% ELSE %]
+                #[% hold.relative_queue_position %] of [% hold.potentials %] copies.
+            [% END %]
+          </td>
+        </tr>
+      </div>
+    </li>
+  [% END %]
+  </ol>
+</div>
+$TEMPLATE$ WHERE name = 'scko_holds';
+
+COMMIT;
+
+