From b1864a92f09f00a5d3c50d1b5df863c961967535 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 10 Feb 2010 17:49:46 +0000 Subject: [PATCH] Patch from Joe Atzberger to add a line item 'worksheet' print template and a helper routine for extracting lineitem attributes git-svn-id: svn://svn.open-ils.org/ILS/trunk@15494 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Trigger/Reactor.pm | 13 ++- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 76 +++++++++++++++++ .../0158.data.titles_received_worksheet.sql | 83 +++++++++++++++++++ 4 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0158.data.titles_received_worksheet.sql diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm index 222b00275c..936e57060b 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm @@ -15,7 +15,6 @@ sub NOOP_False { return 0 } - # helper functions inserted into the TT environment my $_TT_helpers = { @@ -87,6 +86,18 @@ my $_TT_helpers = { my($org_id, $setting) = @_; return $U->ou_ancestor_setting_value($org_id, $setting); }, + + # returns matching line item attribute, or undef + get_li_attr => sub { + my ($name, $type, $attr) = @_; + # use Data::Dumper; $logger->warn("get_li_attr: " . Dumper($attr)); + ($name and @$attr) or return; + foreach (@$attr) { + $_->attr_name eq $name or next; + return $_->attr_value if (! $type) or $type eq $_->attr_type; + } + return; + }, }; diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 3572bfad09..29841912c4 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0157'); -- Scott McKellar +INSERT INTO config.upgrade_log (version) VALUES ('0158'); -- atz CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, 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 dd4a1e8af7..00613fec70 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -3815,6 +3815,82 @@ $$ $$ ); +INSERT INTO action_trigger.hook (key, core_type, description, passive) + VALUES ( + 'format.acqli.html', + 'jub', + 'Formats lineitem worksheet for titles received', + TRUE + ); + +INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, granularity, template) + VALUES ( + 14, + TRUE, + 1, + 'Titles Received Lineitem Worksheet', + 'format.acqli.html', + 'NOOP_True', + 'ProcessTemplate', + 'print-on-demand', +$$ +[%- USE date -%] +[%- SET li = target; -%] +
+
+
Lineitem ID: [% li.id %]
+
[% li.lineitem_details.size %] items
+ [% IF detail.recv_time %]
Expected: [% li.expected_recv_time %]
[% END %] +
+ + + + + + + + + + + + + [% FOREACH detail IN li.lineitem_details %] + + [% IF loop.first %] + + [% END %] + + + + + + + + [% END %] + +
TitleRecd.BarcodeCall NumberDistributionNotes
+ [%- helpers.get_li_attr("title", "", li.attributes) -%] + [% IF detail.recv_time %][% detail.recv_time %][% END %][% IF detail.barcode %][% detail.barcode %][% END %][% IF detail.cn_label %][% detail.cn_label %][% END %] + ==> [% detail.owning_lib.shortname %] ([% detail.owning_lib.name %]) + [% IF detail.note %]( [% detail.note %] )[% END %] + + [%- SET notelist = [] -%] + [%- FOR note IN li.lineitem_notes -%] + [%- notelist.push(note.value) -%] + [%- END -%] + [%- notelist.join('
') -%] +
+
+$$ +); + + +INSERT INTO action_trigger.environment (event_def, path) VALUES + ( 14, 'attributes' ), + ( 14, 'lineitem_details' ), + ( 14, 'lineitem_details.owning_lib' ), + ( 14, 'lineitem_notes' ) +; INSERT INTO action_trigger.environment ( event_def, path) VALUES ( 13, 'open_billable_transactions_summary.circulation' ); diff --git a/Open-ILS/src/sql/Pg/upgrade/0158.data.titles_received_worksheet.sql b/Open-ILS/src/sql/Pg/upgrade/0158.data.titles_received_worksheet.sql new file mode 100644 index 0000000000..23f515fd2e --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0158.data.titles_received_worksheet.sql @@ -0,0 +1,83 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0158'); -- atz + +INSERT INTO action_trigger.hook (key, core_type, description, passive) + VALUES ( + 'format.acqli.html', + 'jub', + 'Formats lineitem worksheet for titles received', + TRUE + ); + +INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, granularity, template) + VALUES ( + 14, + TRUE, + 1, + 'Titles Received Lineitem Worksheet', + 'format.acqli.html', + 'NOOP_True', + 'ProcessTemplate', + 'print-on-demand', +$$ +[%- USE date -%] +[%- SET li = target; -%] +
+
+
Lineitem ID: [% li.id %]
+
[% li.lineitem_details.size %] items
+ [% IF detail.recv_time %]
Expected: [% li.expected_recv_time %]
[% END %] +
+ + + + + + + + + + + + + [% FOREACH detail IN li.lineitem_details %] + + [% IF loop.first %] + + [% END %] + + + + + + + + [% END %] + +
TitleRecd.BarcodeCall NumberDistributionNotes
+ [%- helpers.get_li_attr("title", "", li.attributes) -%] + [% IF detail.recv_time %][% detail.recv_time %][% END %][% IF detail.barcode %][% detail.barcode %][% END %][% IF detail.cn_label %][% detail.cn_label %][% END %] + ==> [% detail.owning_lib.shortname %] ([% detail.owning_lib.name %]) + [% IF detail.note %]( [% detail.note %] )[% END %] + + [%- SET notelist = [] -%] + [%- FOR note IN li.lineitem_notes -%] + [%- notelist.push(note.value) -%] + [%- END -%] + [%- notelist.join('
') -%] +
+
+$$ +); + + +INSERT INTO action_trigger.environment (event_def, path) VALUES + ( 14, 'attributes' ), + ( 14, 'lineitem_details' ), + ( 14, 'lineitem_details.owning_lib' ), + ( 14, 'lineitem_notes' ) +; + +COMMIT; + -- 2.43.2