From: phasefx Date: Mon, 2 Aug 2010 14:17:02 +0000 (+0000) Subject: toward printing slip and letter for missing pieces X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2bdea0de8ccc1f0114a3b9b3e30a0dd8e46c793d;p=evergreen%2Fbjwebb.git toward printing slip and letter for missing pieces git-svn-id: svn://svn.open-ils.org/ILS/trunk@17060 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm index e8db5b008..32ecfe896 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm @@ -1324,12 +1324,14 @@ sub mark_item_missing_pieces { if ($e->commit) { my $ses = OpenSRF::AppSession->create('open-ils.trigger'); - $ses->request('open-ils.trigger.event.autocreate', 'checkout.missing_pieces', $circ, $circ->circ_lib); + $ses->request('open-ils.trigger.event.autocreate', 'circ.missing_pieces', $circ, $circ->circ_lib); return OpenILS::Event->new('SUCCESS', payload => { circ => $circ, - copy => $copy + copy => $copy, + slip => $U->fire_object_event(undef, 'circ.format.missing_pieces.slip.print', $circ, $circ->circ_lib), + letter => $U->fire_object_event(undef, 'circ.format.missing_pieces.letter.print', $circ, $circ->circ_lib) } ); diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index fe2a80003..ec7dbf014 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -68,7 +68,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0354'); -- berick +INSERT INTO config.upgrade_log (version) VALUES ('0355'); -- 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 ff19f82fd..9876e41a8 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -5947,3 +5947,126 @@ INSERT INTO config.org_unit_setting_type (name, label, description, datatype) 'array' ); +-- 0355.data.missing_pieces_format.sql + +INSERT INTO action_trigger.hook (key,core_type,description,passive) VALUES + ( 'circ.format.missing_pieces.slip.print', + 'circ', + oils_i18n_gettext( + 'circ.format.missing_pieces.slip.print', + 'A missing pieces slip needs to be formatted for printing.', + 'ath', + 'description' + ), + FALSE + ) + ,( 'circ.format.missing_pieces.letter.print', + 'circ', + oils_i18n_gettext( + 'circ.format.missing_pieces.letter.print', + 'A missing pieces patron letter 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 ( + 33, + TRUE, + 1, + 'circ.missing_pieces.slip.print', + 'circ.format.missing_pieces.slip.print', + 'NOOP_True', + 'ProcessTemplate', + 'usr', + 'print-on-demand', +$$ +[%- USE date -%] +[%- SET user = target.0.usr -%] +
+
[% date.format %]

+ Missing pieces for: +
    + [% FOR circ IN target %] +
  1. Barcode: [% circ.target_copy.barcode %] Transaction ID: [% circ.id %] Due: [% circ.due_date.format %]
    + [% helpers.get_copy_bib_basics(circ.target_copy.id).title %] +
  2. + [% END %] +
+
+$$ + ) + ,( + 34, + TRUE, + 1, + 'circ.missing_pieces.letter.print', + 'circ.format.missing_pieces.letter.print', + 'NOOP_True', + 'ProcessTemplate', + 'usr', + 'print-on-demand', +$$ +[%- USE date -%] +[%- SET user = target.0.usr -%] +[% date.format %] +Dear [% user.prefix %] [% user.first_given_name %] [% user.family_name %], + +We are missing pieces for the following returned items: +[% FOR circ IN target %] +Barcode: [% circ.target_copy.barcode %] Transaction ID: [% circ.id %] Due: [% circ.due_date.format %] +[% helpers.get_copy_bib_basics(circ.target_copy.id).title %] +[% END %] + +Please return these pieces as soon as possible. + +Thanks! + +Library Staff +$$ + ) +; + +INSERT INTO action_trigger.environment ( + event_def, + path + ) VALUES -- for fleshing circ objects + ( 33, 'usr') + ,( 33, 'target_copy') + ,( 33, 'target_copy.circ_lib') + ,( 33, 'target_copy.circ_lib.mailing_address') + ,( 33, 'target_copy.circ_lib.billing_address') + ,( 33, 'target_copy.call_number') + ,( 33, 'target_copy.call_number.owning_lib') + ,( 33, 'target_copy.call_number.owning_lib.mailing_address') + ,( 33, 'target_copy.call_number.owning_lib.billing_address') + ,( 33, 'circ_lib') + ,( 33, 'circ_lib.mailing_address') + ,( 33, 'circ_lib.billing_address') + ,( 34, 'usr') + ,( 34, 'target_copy') + ,( 34, 'target_copy.circ_lib') + ,( 34, 'target_copy.circ_lib.mailing_address') + ,( 34, 'target_copy.circ_lib.billing_address') + ,( 34, 'target_copy.call_number') + ,( 34, 'target_copy.call_number.owning_lib') + ,( 34, 'target_copy.call_number.owning_lib.mailing_address') + ,( 34, 'target_copy.call_number.owning_lib.billing_address') + ,( 34, 'circ_lib') + ,( 34, 'circ_lib.mailing_address') + ,( 34, 'circ_lib.billing_address') +; + diff --git a/Open-ILS/src/sql/Pg/upgrade/0355.data.missing_pieces_format.sql b/Open-ILS/src/sql/Pg/upgrade/0355.data.missing_pieces_format.sql new file mode 100644 index 000000000..58385f4bf --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0355.data.missing_pieces_format.sql @@ -0,0 +1,129 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0355'); -- phasefx + +INSERT INTO action_trigger.hook (key,core_type,description,passive) VALUES + ( 'circ.format.missing_pieces.slip.print', + 'circ', + oils_i18n_gettext( + 'circ.format.missing_pieces.slip.print', + 'A missing pieces slip needs to be formatted for printing.', + 'ath', + 'description' + ), + FALSE + ) + ,( 'circ.format.missing_pieces.letter.print', + 'circ', + oils_i18n_gettext( + 'circ.format.missing_pieces.letter.print', + 'A missing pieces patron letter 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 ( + 33, + TRUE, + 1, + 'circ.missing_pieces.slip.print', + 'circ.format.missing_pieces.slip.print', + 'NOOP_True', + 'ProcessTemplate', + 'usr', + 'print-on-demand', +$$ +[%- USE date -%] +[%- SET user = target.0.usr -%] +
+
[% date.format %]

+ Missing pieces for: +
    + [% FOR circ IN target %] +
  1. Barcode: [% circ.target_copy.barcode %] Transaction ID: [% circ.id %] Due: [% circ.due_date.format %]
    + [% helpers.get_copy_bib_basics(circ.target_copy.id).title %] +
  2. + [% END %] +
+
+$$ + ) + ,( + 34, + TRUE, + 1, + 'circ.missing_pieces.letter.print', + 'circ.format.missing_pieces.letter.print', + 'NOOP_True', + 'ProcessTemplate', + 'usr', + 'print-on-demand', +$$ +[%- USE date -%] +[%- SET user = target.0.usr -%] +[% date.format %] +Dear [% user.prefix %] [% user.first_given_name %] [% user.family_name %], + +We are missing pieces for the following returned items: +[% FOR circ IN target %] +Barcode: [% circ.target_copy.barcode %] Transaction ID: [% circ.id %] Due: [% circ.due_date.format %] +[% helpers.get_copy_bib_basics(circ.target_copy.id).title %] +[% END %] + +Please return these pieces as soon as possible. + +Thanks! + +Library Staff +$$ + ) +; + +INSERT INTO action_trigger.environment ( + event_def, + path + ) VALUES -- for fleshing circ objects + ( 33, 'usr') + ,( 33, 'target_copy') + ,( 33, 'target_copy.circ_lib') + ,( 33, 'target_copy.circ_lib.mailing_address') + ,( 33, 'target_copy.circ_lib.billing_address') + ,( 33, 'target_copy.call_number') + ,( 33, 'target_copy.call_number.owning_lib') + ,( 33, 'target_copy.call_number.owning_lib.mailing_address') + ,( 33, 'target_copy.call_number.owning_lib.billing_address') + ,( 33, 'circ_lib') + ,( 33, 'circ_lib.mailing_address') + ,( 33, 'circ_lib.billing_address') + ,( 34, 'usr') + ,( 34, 'target_copy') + ,( 34, 'target_copy.circ_lib') + ,( 34, 'target_copy.circ_lib.mailing_address') + ,( 34, 'target_copy.circ_lib.billing_address') + ,( 34, 'target_copy.call_number') + ,( 34, 'target_copy.call_number.owning_lib') + ,( 34, 'target_copy.call_number.owning_lib.mailing_address') + ,( 34, 'target_copy.call_number.owning_lib.billing_address') + ,( 34, 'circ_lib') + ,( 34, 'circ_lib.mailing_address') + ,( 34, 'circ_lib.billing_address') +; + +-- DELETE FROM config.upgrade_log WHERE version = 'temp'; DELETE FROM action_trigger.event WHERE event_def IN (33,34); DELETE FROM action_trigger.environment WHERE event_def IN (33,34); DELETE FROM action_trigger.event_definition WHERE id IN (33,34); DELETE FROM action_trigger.hook WHERE key IN ( 'circ.format.missing_pieces.slip.print', 'circ.format.missing_pieces.letter.print' ); + +COMMIT; + diff --git a/Open-ILS/xul/staff_client/server/cat/util.js b/Open-ILS/xul/staff_client/server/cat/util.js index d4a01abf2..c594ac94f 100644 --- a/Open-ILS/xul/staff_client/server/cat/util.js +++ b/Open-ILS/xul/staff_client/server/cat/util.js @@ -759,11 +759,18 @@ cat.util.mark_item_as_missing_pieces = function(copy_ids) { for (var i = 0; i < copies.length; i++) { try { var robj = network.simple_request('MARK_ITEM_MISSING_PIECES',[ses(),copies[i].id()]); - if (typeof robj.ilsevent != 'undefined') { throw(robj); } - // TODO: Print missing pieces slip - // TODO: Bill patron prompt - // TODO: Item/patron notes/messages - // TODO: Invoke 3rd party app with letter to patron + if (typeof robj.ilsevent != 'undefined') { + if (robj.ilsevent == 0 /* SUCCESS */) { + // TODO: Print missing pieces slip + // TODO: Item/patron notes/messages + // TODO: Invoke 3rd party app with letter to patron + } else if (robj.ilsevent == 1500 /* ACTION_CIRCULATION_NOT_FOUND */) { + } else { + throw(robj); + } + } else { + throw(robj); + } count++; } catch(E) { error.standard_unexpected_error_alert($("catStrings").getFormattedString('staff.cat.util.mark_item_missing_pieces.marking_error', [copies[i].barcode()]),E);