return things;
}
+
+ // Returns a random-ish date in the past or the future.
+ randomDate(future: boolean = false): Date {
+ const rando = Math.random() * 10000000000;
+ const time = new Date().getTime();
+ return new Date(future ? time + rando : time - rando);
+ }
}
classes.forEach(class_ => samples[class_] =
this.idl.toHash(this.samples.listOfThings(class_, 10)))
- // Flesh some patrons with cards
- const patron0 = this.idl.clone(samples.au[0]);
- const patron1 = this.idl.clone(samples.au[1]);
- const patron2 = this.idl.clone(samples.au[2]);
- patron0.card = samples.ac[0];
- patron1.card = samples.ac[1];
- patron2.card = samples.ac[2];
+ // Wide holds are hashes instead of IDL objects.
+ // Add fields as needed.
+ const wide_holds = [{
+ request_time: this.samples.randomDate().toISOString(),
+ ucard_barcode: samples.ac[0].barcode,
+ usr_family_name: samples.au[0].family_name,
+ usr_alias: samples.au[0].alias,
+ cp_barcode: samples.acp[0].barcode
+ }, {
+ request_time: this.samples.randomDate().toISOString(),
+ ucard_barcode: samples.ac[1].barcode,
+ usr_family_name: samples.au[1].family_name,
+ usr_alias: samples.au[1].alias,
+ cp_barcode: samples.acp[1].barcode
+ }];
this.sampleData.patron_address = {
patron: samples.au[0],
address: samples.aua[0]
};
- this.sampleData.holds_for_bib = {
- title: samples.mwde[0].title,
- holds: [
- {
- hold: samples.ahr[0],
- patron: patron0,
- copy: samples.acp[0]
- }, {
- hold: samples.ahr[1],
- patron: patron1,
- copy: samples.acp[1]
- }
- ]
- };
+ this.sampleData.holds_for_bib = wide_holds;
}
onTabChange(evt: NgbTabChangeEvent) {
<ng-template ngbTabContent>
<eg-holds-grid [recordId]="recordId"
preFetchSetting="catalog.record.holds.prefetch"
+ printTemplate="holds_for_bib"
persistKey="cat.catalog.wide_holds"
[defaultSort]="[{name:'request_time',dir:'asc'}]"
[initialPickupLib]="currentSearchOrg()"></eg-holds-grid>
@Input() persistKey: string;
@Input() preFetchSetting: string;
- // If set, all holds are fetched on grid load and sorting/paging all
+
+ @Input() printTemplate: string;
+
+ // If set, all holds are fetched on grid load and sorting/paging all
// happens in the client. If false, sorting and paging occur on
// the server.
enablePreFetch: boolean;
private net: NetService,
private org: OrgService,
private store: ServerStoreService,
- private auth: AuthService
+ private auth: AuthService,
+ private printer: PrintService
) {
this.gridDataSource = new GridDataSource();
this.enablePreFetch = null;
}
printHolds() {
+ // Request a page with no limit to get all of the wide holds for
+ // printing. Call requestPage() directly instead of grid.reload()
+ // since we may already have the data.
+
+ const pager = new Pager();
+ pager.offset = 0;
+ pager.limit = null;
+
+ if (this.gridDataSource.sort.length == 0) {
+ this.gridDataSource.sort = this.defaultSort;
+ }
+
+ this.gridDataSource.requestPage(pager).then(() => {
+ if (this.gridDataSource.data.length > 0) {
+ this.printer.print({
+ templateName: this.printTemplate || 'holds_for_bib',
+ contextData: this.gridDataSource.data,
+ printContext: 'default'
+ });
+ }
+ });
}
}
unless $e->checkauth && $e->requestor->wsid;
# Let pcrud handle the authz
- $e->personality('open-ils.pcrud');
+ # TODO: setting ->personality applies globally which breaks other
+ # Apache mod_perl handlers. Allow for per-editor personalities.
+ #$e->personality('open-ils.pcrud');
my $tmpl_owner = $cgi->param('template_owner') || $e->requestor->ws_ou;
my $tmpl_locale = $cgi->param('template_locale') || 'en-US';
$TEMPLATE$
);
+INSERT INTO config.print_template
+ (id, name, locale, active, owner, label, template)
+VALUES (
+ 2, 'holds_for_bib', 'en-US', FALSE,
+ (SELECT id FROM actor.org_unit WHERE parent_ou IS NULL),
+ oils_i18n_gettext(2, 'Holds for Bib Record', 'cpt', 'label'),
+$TEMPLATE$
+[%-
+ USE date;
+ SET holds = template_data;
+ # template_data is an arry of wide_hold hashes.
+-%]
+<div>
+ <div>Holds for record: [% holds.0.title %]</div>
+ <hr/>
+ <style>#holds-for-bib-table td { padding: 5px; }</style>
+ <table id="holds-for-bib-table">
+ <thead>
+ <tr>
+ <th>Request Date</th>
+ <th>Patron Barcode</th>
+ <th>Patron Last</th>
+ <th>Patron Alias</th>
+ <th>Current Item</th>
+ </tr>
+ </thead>
+ <tbody>
+ [% FOR hold IN holds %]
+ <tr>
+ <td>[%
+ date.format(helpers.format_date(
+ hold.request_time, staff_org_timezone), '%x %r', locale)
+ %]</td>
+ <td>[% hold.ucard_barcode %]</td>
+ <td>[% hold.usr_family_name %]</td>
+ <td>[% hold.usr_alias %]</td>
+ <td>[% hold.cp_barcode %]</td>
+ </tr>
+ [% END %]
+ </tbody>
+ </table>
+ <hr/>
+ <div>
+ [% staff_org.shortname %]
+ [% date.format(helpers.current_date(client_timezone), '%x %r', locale) %]
+ </div>
+ <div>Printed by [% staff.first_given_name %]</div>
+</div>
+<br/>
+
+$TEMPLATE$
+);
+
+
-- Allow for 1k stock templates
SELECT SETVAL('config.print_template_id_seq'::TEXT, 1000);
2, 'holds_for_bib', 'en-US', FALSE,
(SELECT id FROM actor.org_unit WHERE parent_ou IS NULL),
oils_i18n_gettext(2, 'Holds for Bib Record', 'cpt', 'label'),
+$TEMPLATE$
[%-
USE date;
- SET holds = template_data.holds;
- SET title = template_data.title;
+ SET holds = template_data;
+ # template_data is an arry of wide_hold hashes.
-%]
<div>
- <div>Holds for record: [% title %]</div>
+ <div>Holds for record: [% holds.0.title %]</div>
<hr/>
<style>#holds-for-bib-table td { padding: 5px; }</style>
<table id="holds-for-bib-table">
<tr>
<td>[%
date.format(helpers.format_date(
- hold.hold.request_time, staff_org_timezone), '%x %r', locale)
+ hold.request_time, staff_org_timezone), '%x %r', locale)
%]</td>
- <td>[% hold.patron.card.barcode %]</td>
- <td>[% hold.patron.family_name %]</td>
- <td>[% hold.patron.alias %]</td>
- <td>[% hold.copy.barcode %]</td>
+ <td>[% hold.ucard_barcode %]</td>
+ <td>[% hold.usr_family_name %]</td>
+ <td>[% hold.usr_alias %]</td>
+ <td>[% hold.cp_barcode %]</td>
</tr>
[% END %]
</tbody>
if (OpenSRF.locale) {
// .append() coerces arguments to strings, so if locale
// is null, the server will get the string "null"
- formData.append('locale', OpenSRF.locale);
+ formData.append('template_locale', OpenSRF.locale);
}
return new Promise((resolve, reject) => {