]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/support-scripts/test-scripts/print_aur.pl
Merge branch 'master' of git.evergreen-ils.org:Evergreen-DocBook into doc_consolidati...
[Evergreen.git] / Open-ILS / src / support-scripts / test-scripts / print_aur.pl
1 #!/usr/bin/perl
2
3 #----------------------------------------------------------------
4 # Print AUR
5 #----------------------------------------------------------------
6
7 require '../oils_header.pl';
8 use vars qw/$apputils/;
9 use strict;
10 use Data::Dumper;
11 my $config              = shift; 
12 my $username    = shift || 'admin';
13 my $password    = shift || 'open-ils';
14 my $aur_id       = shift;
15 my $hook        = shift || 'aur.ordered';
16
17 osrf_connect($config);
18 oils_login($username, $password);
19 my $e = OpenILS::Utils::CStoreEditor->new;
20
21 my $aur = $e->retrieve_acq_user_request($aur_id) or oils_event_die($e->event);
22 my $orgs = $apputils->get_org_ancestors($aur->pickup_lib);
23 my $defs = $e->search_action_trigger_event_definition({hook => $hook, owner => $orgs});
24 $defs = [sort { $a->id cmp $b->id } @$defs ]; # this is a brittle hack, but.. meh
25 my $def = pop @$defs;
26 print "using def " . $def->id . " at org_unit " . $def->owner . "\n";
27
28 die "No event_definition found with hook $hook\n" unless $def;
29
30 my $event_id = $apputils->simplereq(
31     'open-ils.trigger', 
32     'open-ils.trigger.event.autocreate.by_definition.include_inactive',
33     $def->id, $aur, $aur->pickup_lib);
34
35
36 my $result = $apputils->simplereq(
37     'open-ils.trigger',
38     'open-ils.trigger.event.fire', $event_id);
39
40
41 print "Event state is " . $result->{event}->state . "\n";
42
43 my $event = $e->retrieve_action_trigger_event(
44     [
45         $event_id, 
46         {flesh => 1, flesh_fields => {atev => ['template_output', 'error_output']}}
47     ]
48 );
49
50 if($event->template_output) {
51     print $event->template_output->data . "\n";
52 }
53 if($event->error_output) {
54     print $event->error_output->data . "\n";
55 }
56