From c7368f1cce63ad3fadade381fd102cdae97f1fb9 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 29 Feb 2012 10:49:18 -0500 Subject: [PATCH] Tpac: record detail print and email Implements Print and Email actions (as links below add-to-list) in the tpac record detail page. The existing bib record print/email A/T seed templates were also updated like so: * Instead of using the reporter tables, bib data is fetched and extracted via unapi, which allows access to SVF data (etc) and is more consistent with the tpac. * A number of unused A/T evnironment entries for the seed templates were removed. * The delay for the email template was explicitly set to 00:00:00 instead of the default 5 minutes to get the emails out quicker. Signed-off-by: Bill Erickson --- .../perlmods/lib/OpenILS/WWW/EGCatLoader.pm | 5 +- .../lib/OpenILS/WWW/EGCatLoader/Record.pm | 29 ++++++ Open-ILS/src/sql/Pg/950.data.seed-values.sql | 80 +++++++++------ .../XXXX.data.record_print_format_update.sql | 98 +++++++++++++++++++ .../templates/opac/parts/record/summary.tt2 | 7 +- Open-ILS/src/templates/opac/record/email.tt2 | 21 ++++ Open-ILS/src/templates/opac/record/print.tt2 | 27 +++++ 7 files changed, 237 insertions(+), 30 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.record_print_format_update.sql create mode 100644 Open-ILS/src/templates/opac/record/email.tt2 create mode 100644 Open-ILS/src/templates/opac/record/print.tt2 diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index 755f403485..c333023b8b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -99,7 +99,8 @@ sub load { $path =~ m:opac/(advanced|numeric|expert):; return $self->load_rresults if $path =~ m|opac/results|; - return $self->load_record if $path =~ m|opac/record|; + return $self->load_print_record if $path =~ m|opac/record/print|; + return $self->load_record if $path =~ m|opac/record/\d|; return $self->load_cnbrowse if $path =~ m|opac/cnbrowse|; return $self->load_mylist_add if $path =~ m|opac/mylist/add|; @@ -139,6 +140,8 @@ sub load { # ---------------------------------------------------------------- return $self->redirect_auth unless $self->editor->requestor; + return $self->load_email_record if $path =~ m|opac/record/email|; + return $self->load_place_hold if $path =~ m|opac/place_hold|; return $self->load_myopac_holds if $path =~ m|opac/myopac/holds|; return $self->load_myopac_circs if $path =~ m|opac/myopac/circs|; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index e977a47b28..e2cf2bcdcc 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -363,4 +363,33 @@ sub get_hold_copy_summary { $search->kill_me; } +sub load_print_record { + my $self = shift; + + my $rec_id = $self->ctx->{page_args}->[0] + or return Apache2::Const::HTTP_BAD_REQUEST; + + $self->{ctx}->{bre_id} = $rec_id; + $self->{ctx}->{printable_record} = $U->simplereq( + 'open-ils.search', + 'open-ils.search.biblio.record.print', $rec_id); + + return Apache2::Const::OK; +} + +sub load_email_record { + my $self = shift; + + my $rec_id = $self->ctx->{page_args}->[0] + or return Apache2::Const::HTTP_BAD_REQUEST; + + $self->{ctx}->{bre_id} = $rec_id; + $U->simplereq( + 'open-ils.search', + 'open-ils.search.biblio.record.email', + $self->ctx->{authtoken}, $rec_id); + + return Apache2::Const::OK; +} + 1; diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 3e6346b625..bc3321f756 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -8486,6 +8486,7 @@ INSERT INTO action_trigger.event_definition ( cleanup_failure, group_field, granularity, + delay, template ) VALUES ( 31, @@ -8499,22 +8500,42 @@ INSERT INTO action_trigger.event_definition ( 'DeleteTempBiblioBucket', 'owner', NULL, + '00:00:00' $$ -[%- USE date -%] [%- SET user = target.0.owner -%] To: [%- params.recipient_email || user.email %] From: [%- params.sender_email || default_sender %] Subject: Bibliographic Records - [% FOR cbreb IN target %] - [% FOR cbrebi IN cbreb.items %] - Bib ID# [% cbrebi.target_biblio_record_entry.id %] ISBN: [% crebi.target_biblio_record_entry.simple_record.isbn %] - Title: [% cbrebi.target_biblio_record_entry.simple_record.title %] - Author: [% cbrebi.target_biblio_record_entry.simple_record.author %] - Publication Year: [% cbrebi.target_biblio_record_entry.simple_record.pubdate %] +[% FOR cbreb IN target %] +[% FOR item IN cbreb.items; + bre_id = item.target_biblio_record_entry; - [% END %] - [% END %] + bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'}); + FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]'); + title = title _ part.textContent; + END; + + author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent; + item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value'); + publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent; + pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent; + isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent; + issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent; + upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent; +%] + +[% loop.count %]/[% loop.size %]. Bib ID# [% bre_id %] +[% IF isbn %]ISBN: [% isbn _ "\n" %][% END -%] +[% IF issn %]ISSN: [% issn _ "\n" %][% END -%] +[% IF upc %]UPC: [% upc _ "\n" %] [% END -%] +Title: [% title %] +Author: [% author %] +Publication Info: [% publisher %] [% pubdate %] +Item Type: [% item_type %] + +[% END %] +[% END %] $$ ) ,( @@ -8529,17 +8550,33 @@ $$ 'DeleteTempBiblioBucket', 'owner', 'print-on-demand', + NULL, $$ -[%- USE date -%]
    [% FOR cbreb IN target %] - [% FOR cbrebi IN cbreb.items %] -
  1. Bib ID# [% cbrebi.target_biblio_record_entry.id %] ISBN: [% crebi.target_biblio_record_entry.simple_record.isbn %]
    - Title: [% cbrebi.target_biblio_record_entry.simple_record.title %]
    - Author: [% cbrebi.target_biblio_record_entry.simple_record.author %]
    - Publication Year: [% cbrebi.target_biblio_record_entry.simple_record.pubdate %] + [% FOR item IN cbreb.items; + bre_id = item.target_biblio_record_entry; + + bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'}); + FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]'); + title = title _ part.textContent; + END; + + author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent; + item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value'); + publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent; + pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent; + isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent; + %] + +
  2. + Bib ID# [% bre_id %] ISBN: [% isbn %]
    + Title: [% title %]
    + Author: [% author %]
    + Publication Info: [% publisher %] [% pubdate %]
    + Item Type: [% item_type %]
  3. [% END %] [% END %] @@ -8555,20 +8592,7 @@ INSERT INTO action_trigger.environment ( ) VALUES -- for fleshing cbreb objects ( 31, 'owner' ) ,( 31, 'items' ) - ,( 31, 'items.target_biblio_record_entry' ) - ,( 31, 'items.target_biblio_record_entry.simple_record' ) - ,( 31, 'items.target_biblio_record_entry.call_numbers' ) - ,( 31, 'items.target_biblio_record_entry.fixed_fields' ) - ,( 31, 'items.target_biblio_record_entry.notes' ) - ,( 31, 'items.target_biblio_record_entry.full_record_entries' ) - ,( 32, 'owner' ) ,( 32, 'items' ) - ,( 32, 'items.target_biblio_record_entry' ) - ,( 32, 'items.target_biblio_record_entry.simple_record' ) - ,( 32, 'items.target_biblio_record_entry.call_numbers' ) - ,( 32, 'items.target_biblio_record_entry.fixed_fields' ) - ,( 32, 'items.target_biblio_record_entry.notes' ) - ,( 32, 'items.target_biblio_record_entry.full_record_entries' ) ; INSERT INTO acq.invoice_item_type (code,name) VALUES ('TAX',oils_i18n_gettext('TAX', 'Tax', 'aiit', 'name')); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.record_print_format_update.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.record_print_format_update.sql new file mode 100644 index 0000000000..fa31353719 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.record_print_format_update.sql @@ -0,0 +1,98 @@ + + +UPDATE action_trigger.event_definition SET template = $$ +
    + +
      + [% FOR cbreb IN target %] + [% FOR item IN cbreb.items; + bre_id = item.target_biblio_record_entry; + + bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'}); + FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]'); + title = title _ part.textContent; + END; + + author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent; + item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value'); + publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent; + pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent; + isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent; + issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent; + upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent; + %] + +
    1. + Bib ID# [% bre_id %]
      + [% IF isbn %]ISBN: [% isbn %]
      [% END %] + [% IF issn %]ISSN: [% issn %]
      [% END %] + [% IF upc %]UPC: [% upc %]
      [% END %] + Title: [% title %]
      + Author: [% author %]
      + Publication Info: [% publisher %] [% pubdate %]
      + Item Type: [% item_type %] +
    2. + [% END %] + [% END %] +
    +
    +$$ +WHERE hook = 'biblio.format.record_entry.print' AND id < 100; -- sample data + + +UPDATE action_trigger.event_definition SET delay = '00:00:00', template = $$ +[%- SET user = target.0.owner -%] +To: [%- params.recipient_email || user.email %] +From: [%- params.sender_email || default_sender %] +Subject: Bibliographic Records + +[% FOR cbreb IN target %] +[% FOR item IN cbreb.items; + bre_id = item.target_biblio_record_entry; + + bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'}); + FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]'); + title = title _ part.textContent; + END; + + author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent; + item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value'); + publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent; + pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent; + isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent; + issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent; + upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent; +%] + +[% loop.count %]/[% loop.size %]. Bib ID# [% bre_id %] +[% IF isbn %]ISBN: [% isbn _ "\n" %][% END -%] +[% IF issn %]ISSN: [% issn _ "\n" %][% END -%] +[% IF upc %]UPC: [% upc _ "\n" %] [% END -%] +Title: [% title %] +Author: [% author %] +Publication Info: [% publisher %] [% pubdate %] +Item Type: [% item_type %] + +[% END %] +[% END %] +$$ +WHERE hook = 'biblio.format.record_entry.email' AND id < 100; -- sample data + +-- remove a swath of unused environment entries + +DELETE FROM action_trigger.environment env + USING action_trigger.event_definition def + WHERE env.event_def = def.id AND + env.path != 'items' AND + def.hook = 'biblio.format.record_entry.print' AND + def.id < 100; -- sample data + +DELETE FROM action_trigger.environment env + USING action_trigger.event_definition def + WHERE env.event_def = def.id AND + env.path != 'items' AND + env.path != 'owner' AND + def.hook = 'biblio.format.record_entry.email' AND + def.id < 100; -- sample data + + diff --git a/Open-ILS/src/templates/opac/parts/record/summary.tt2 b/Open-ILS/src/templates/opac/parts/record/summary.tt2 index f62c5312e7..7ca150eb06 100644 --- a/Open-ILS/src/templates/opac/parts/record/summary.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/summary.tt2 @@ -11,7 +11,7 @@
    -[%- # This holds the record summary information %] +[%-# This holds the record summary information %]
    [% ident = attrs.isbn_clean || attrs.upc; IF ident; %] @@ -39,6 +39,11 @@ [% label %]
    +
    [%- IF attrs.format_icon %] diff --git a/Open-ILS/src/templates/opac/record/email.tt2 b/Open-ILS/src/templates/opac/record/email.tt2 new file mode 100644 index 0000000000..bafd20aa98 --- /dev/null +++ b/Open-ILS/src/templates/opac/record/email.tt2 @@ -0,0 +1,21 @@ +[% PROCESS "opac/parts/header.tt2"; + PROCESS "opac/parts/config.tt2"; + WRAPPER "opac/parts/base.tt2"; + INCLUDE "opac/parts/topnav.tt2"; + ctx.page_title = l("Record Detail") %] +
    + [% INCLUDE "opac/parts/searchbar.tt2" %] +
    +
    +
    +
    +
    +

    [% l('Your email has been queued for Delivery.') %]

    +
    +

    [ [% l("Back to Record") %] ]

    +
    +
    +
    +
    +[% END %] + diff --git a/Open-ILS/src/templates/opac/record/print.tt2 b/Open-ILS/src/templates/opac/record/print.tt2 new file mode 100644 index 0000000000..d5d94e615b --- /dev/null +++ b/Open-ILS/src/templates/opac/record/print.tt2 @@ -0,0 +1,27 @@ +[% PROCESS 'opac/parts/header.tt2' %] + + + [% l('Print Record') %] + + + + [% IF ctx.printable_record.template_output %] + + [% ctx.printable_record.template_output.data %] + + [% ELSE %] + + [% END %] + + + -- 2.43.2