From c07e8dcc4871a2a29168762b801f91a58a358bcf Mon Sep 17 00:00:00 2001 From: phasefx Date: Fri, 28 May 2010 21:35:03 +0000 Subject: [PATCH] templates and methods for print/email of historical hold/circ lists git-svn-id: svn://svn.open-ils.org/ILS/trunk@16533 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 190 ++++++++++++++++++++ .../sql/Pg/upgrade/0285.data.history_format.sql | 195 +++++++++++++++++++++ 3 files changed, 386 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0285.data.history_format.sql diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 7347bd9be9..38be33104d 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -65,7 +65,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0284'); -- Scott McKellar +INSERT INTO config.upgrade_log (version) VALUES ('0285'); -- phasefx 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 9dcbecd385..7d9db2e68e 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -4908,6 +4908,196 @@ INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) 'bool' ); +-- 0285.data.history_format.sql + +INSERT INTO action_trigger.hook (key,core_type,description,passive) VALUES ( + 'circ.format.history.email', + 'circ', + oils_i18n_gettext( + 'circ.format.history.email', + 'An email has been requested for a circ history.', + 'ath', + 'description' + ), + FALSE + ) + ,( + 'circ.format.history.print', + 'circ', + oils_i18n_gettext( + 'circ.format.history.print', + 'A circ history needs to be formatted for printing.', + 'ath', + 'description' + ), + FALSE + ) + ,( + 'ahr.format.history.email', + 'ahr', + oils_i18n_gettext( + 'ahr.format.history.email', + 'An email has been requested for a hold request history.', + 'ath', + 'description' + ), + FALSE + ) + ,( + 'ahr.format.history.print', + 'ahr', + oils_i18n_gettext( + 'ahr.format.history.print', + 'A hold request history needs to be formatted for printing.', + 'ath', + 'description' + ), + FALSE + ) + +; + +INSERT INTO action_trigger.event_definition ( + id, + active, + owner, + name, + hook, + validator, + reactor, + group_field, + granularity, + template + ) VALUES ( + 25, + TRUE, + 1, + 'circ.history.email', + 'circ.format.history.email', + 'NOOP_True', + 'SendEmail', + 'usr', + NULL, +$$ +[%- USE date -%] +[%- SET user = target.0.usr -%] +To: [%- params.recipient_email || user.email %] +From: [%- params.sender_email || default_sender %] +Subject: Circulation History + + [% FOR circ IN target %] + [% helpers.get_copy_bib_basics(circ.target_copy.id).title %] + Barcode: [% circ.target_copy.barcode %] + Checked Out: [% date.format(helpers.format_date(circ.xact_start), '%Y-%m-%d') %] + Due Date: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %] + Returned: [% date.format(helpers.format_date(circ.checkin_time), '%Y-%m-%d') %] + [% END %] +$$ + ) + ,( + 26, + TRUE, + 1, + 'circ.history.print', + 'circ.format.history.print', + 'NOOP_True', + 'ProcessTemplate', + 'usr', + 'print-on-demand', +$$ +[%- USE date -%] +
+ +
[% date.format %]
+
+ + [% user.family_name %], [% user.first_given_name %] +
    + [% FOR circ IN target %] +
  1. +
    [% helpers.get_copy_bib_basics(circ.target_copy.id).title %]
    +
    Barcode: [% circ.target_copy.barcode %]
    +
    Checked Out: [% date.format(helpers.format_date(circ.xact_start), '%Y-%m-%d') %]
    +
    Due Date: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]
    +
    Returned: [% date.format(helpers.format_date(circ.checkin_time), '%Y-%m-%d') %]
    +
  2. + [% END %] +
+
+$$ + ) + ,( + 27, + TRUE, + 1, + 'ahr.history.email', + 'ahr.format.history.email', + 'NOOP_True', + 'SendEmail', + 'usr', + NULL, +$$ +[%- USE date -%] +[%- SET user = target.0.usr -%] +To: [%- params.recipient_email || user.email %] +From: [%- params.sender_email || default_sender %] +Subject: Hold Request History + + [% FOR hold IN target %] + [% helpers.get_copy_bib_basics(hold.current_copy.id).title %] + Requested: [% date.format(helpers.format_date(hold.request_time), '%Y-%m-%d') %] + [% IF hold.fulfillment_time %]Fulfilled: [% date.format(helpers.format_date(hold.fulfillment_time), '%Y-%m-%d') %][% END %] + [% END %] +$$ + ) + ,( + 28, + TRUE, + 1, + 'ahr.history.print', + 'ahr.format.history.print', + 'NOOP_True', + 'ProcessTemplate', + 'usr', + 'print-on-demand', +$$ +[%- USE date -%] +
+ +
[% date.format %]
+
+ + [% user.family_name %], [% user.first_given_name %] +
    + [% FOR hold IN target %] +
  1. +
    [% helpers.get_copy_bib_basics(hold.current_copy.id).title %]
    +
    Requested: [% date.format(helpers.format_date(hold.request_time), '%Y-%m-%d') %]
    + [% IF hold.fulfillment_time %]
    Fulfilled: [% date.format(helpers.format_date(hold.fulfillment_time), '%Y-%m-%d') %]
    [% END %] +
  2. + [% END %] +
+
+$$ + ) + +; + +INSERT INTO action_trigger.environment ( + event_def, + path + ) VALUES + ( 25, 'target_copy') + ,( 25, 'usr' ) + ,( 26, 'target_copy' ) + ,( 26, 'usr' ) + ,( 27, 'current_copy' ) + ,( 27, 'usr' ) + ,( 28, 'current_copy' ) + ,( 28, 'usr' ) +; + + -- Org unit settings for fund spending limits INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) diff --git a/Open-ILS/src/sql/Pg/upgrade/0285.data.history_format.sql b/Open-ILS/src/sql/Pg/upgrade/0285.data.history_format.sql new file mode 100644 index 0000000000..1bf34b6979 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0285.data.history_format.sql @@ -0,0 +1,195 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0285'); -- phasefx + +INSERT INTO action_trigger.hook (key,core_type,description,passive) VALUES ( + 'circ.format.history.email', + 'circ', + oils_i18n_gettext( + 'circ.format.history.email', + 'An email has been requested for a circ history.', + 'ath', + 'description' + ), + FALSE + ) + ,( + 'circ.format.history.print', + 'circ', + oils_i18n_gettext( + 'circ.format.history.print', + 'A circ history needs to be formatted for printing.', + 'ath', + 'description' + ), + FALSE + ) + ,( + 'ahr.format.history.email', + 'ahr', + oils_i18n_gettext( + 'ahr.format.history.email', + 'An email has been requested for a hold request history.', + 'ath', + 'description' + ), + FALSE + ) + ,( + 'ahr.format.history.print', + 'ahr', + oils_i18n_gettext( + 'ahr.format.history.print', + 'A hold request history needs to be formatted for printing.', + 'ath', + 'description' + ), + FALSE + ) + +; + +INSERT INTO action_trigger.event_definition ( + id, + active, + owner, + name, + hook, + validator, + reactor, + group_field, + granularity, + template + ) VALUES ( + 25, + TRUE, + 1, + 'circ.history.email', + 'circ.format.history.email', + 'NOOP_True', + 'SendEmail', + 'usr', + NULL, +$$ +[%- USE date -%] +[%- SET user = target.0.usr -%] +To: [%- params.recipient_email || user.email %] +From: [%- params.sender_email || default_sender %] +Subject: Circulation History + + [% FOR circ IN target %] + [% helpers.get_copy_bib_basics(circ.target_copy.id).title %] + Barcode: [% circ.target_copy.barcode %] + Checked Out: [% date.format(helpers.format_date(circ.xact_start), '%Y-%m-%d') %] + Due Date: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %] + Returned: [% date.format(helpers.format_date(circ.checkin_time), '%Y-%m-%d') %] + [% END %] +$$ + ) + ,( + 26, + TRUE, + 1, + 'circ.history.print', + 'circ.format.history.print', + 'NOOP_True', + 'ProcessTemplate', + 'usr', + 'print-on-demand', +$$ +[%- USE date -%] +
+ +
[% date.format %]
+
+ + [% user.family_name %], [% user.first_given_name %] +
    + [% FOR circ IN target %] +
  1. +
    [% helpers.get_copy_bib_basics(circ.target_copy.id).title %]
    +
    Barcode: [% circ.target_copy.barcode %]
    +
    Checked Out: [% date.format(helpers.format_date(circ.xact_start), '%Y-%m-%d') %]
    +
    Due Date: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]
    +
    Returned: [% date.format(helpers.format_date(circ.checkin_time), '%Y-%m-%d') %]
    +
  2. + [% END %] +
+
+$$ + ) + ,( + 27, + TRUE, + 1, + 'ahr.history.email', + 'ahr.format.history.email', + 'NOOP_True', + 'SendEmail', + 'usr', + NULL, +$$ +[%- USE date -%] +[%- SET user = target.0.usr -%] +To: [%- params.recipient_email || user.email %] +From: [%- params.sender_email || default_sender %] +Subject: Hold Request History + + [% FOR hold IN target %] + [% helpers.get_copy_bib_basics(hold.current_copy.id).title %] + Requested: [% date.format(helpers.format_date(hold.request_time), '%Y-%m-%d') %] + [% IF hold.fulfillment_time %]Fulfilled: [% date.format(helpers.format_date(hold.fulfillment_time), '%Y-%m-%d') %][% END %] + [% END %] +$$ + ) + ,( + 28, + TRUE, + 1, + 'ahr.history.print', + 'ahr.format.history.print', + 'NOOP_True', + 'ProcessTemplate', + 'usr', + 'print-on-demand', +$$ +[%- USE date -%] +
+ +
[% date.format %]
+
+ + [% user.family_name %], [% user.first_given_name %] +
    + [% FOR hold IN target %] +
  1. +
    [% helpers.get_copy_bib_basics(hold.current_copy.id).title %]
    +
    Requested: [% date.format(helpers.format_date(hold.request_time), '%Y-%m-%d') %]
    + [% IF hold.fulfillment_time %]
    Fulfilled: [% date.format(helpers.format_date(hold.fulfillment_time), '%Y-%m-%d') %]
    [% END %] +
  2. + [% END %] +
+
+$$ + ) + +; + +INSERT INTO action_trigger.environment ( + event_def, + path + ) VALUES + ( 25, 'target_copy') + ,( 25, 'usr' ) + ,( 26, 'target_copy' ) + ,( 26, 'usr' ) + ,( 27, 'current_copy' ) + ,( 27, 'usr' ) + ,( 28, 'current_copy' ) + ,( 28, 'usr' ) +; + +-- DELETE FROM action_trigger.environment WHERE event_def IN (25,26,27,28); DELETE FROM action_trigger.event where event_def IN (25,26,27,28); DELETE FROM action_trigger.event_definition WHERE id IN (25,26,27,28); DELETE FROM action_trigger.hook WHERE key IN ('circ.format.history.email','circ.format.history.print','ahr.format.history.email','ahr.format.history.print'); DELETE FROM config.upgrade_log WHERE version = 'test'; -- from testing, this sql will remove these events, etc. + +COMMIT; + -- 2.11.0