]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/MarkItemLost.pm
Make Evergreen Perl modules installable via Module::Build to match OpenSRF
[Evergreen.git] / Open-ILS / src / perlmods / lib / OpenILS / Application / Trigger / Reactor / MarkItemLost.pm
1 package OpenILS::Application::Trigger::Reactor::MarkItemLost;
2 use base 'OpenILS::Application::Trigger::Reactor';
3 use strict; use warnings;
4 use Error qw/:try/;
5 use Data::Dumper;
6 use OpenSRF::Utils::Logger qw/:logger/;
7 use OpenILS::Utils::CStoreEditor q/:funcs/;
8 use OpenILS::Application::Cat::AssetCommon;
9 $Data::Dumper::Indent = 0;
10
11
12 sub ABOUT {
13     return <<ABOUT;
14     
15     Marks circulation and corresponding item as lost.  This uses
16     the standard mark-lost functionality, creating billings where appropriate.
17
18     Required event parameters:
19         "editor" which points to a user ID.  This is the user that effectively
20         performs the action.  For example, when the copy status is updated,
21         this user is entered as the last editor of the copy.
22
23 ABOUT
24 }
25
26 sub handler {
27     my $self = shift;
28     my $env = shift;
29     my $e = new_editor(xact => 1);
30     $e->requestor($e->retrieve_actor_user($$env{params}{editor}));
31
32     my $circ = $$env{target};
33     my $evt = OpenILS::Application::Cat::AssetCommon->set_item_lost($e, $circ->target_copy);
34     if($evt) {
35         $logger->error("trigger: MarkItemLost failed with event ".$evt->{textcode});
36         return 0;
37     }
38
39     $e->commit;
40
41     my $ses = OpenSRF::AppSession->create('open-ils.trigger');
42     $ses->request('open-ils.trigger.event.autocreate', 'lost.auto', $circ, $circ->circ_lib);
43
44     return 1;
45 }
46
47 1;