2 # An object to handle checkout status
5 package OpenILS::SIP::Transaction::Checkout;
10 use POSIX qw(strftime);
13 use OpenILS::SIP::Transaction;
14 use Sys::Syslog qw(syslog);
16 use OpenILS::Application::AppUtils;
17 my $U = 'OpenILS::Application::AppUtils';
20 our @ISA = qw(OpenILS::SIP::Transaction);
22 # Most fields are handled by the Transaction superclass
24 security_inhibit => 0,
32 my $self = $class->SUPER::new(@_);
36 foreach $element (keys %fields) {
37 $self->{_permitted}->{$element} = $fields{$element};
40 @{$self}{keys %fields} = values %fields;
42 return bless $self, $class;
46 # if this item is already checked out to the requested patron,
47 # renew the item and set $self->renew_ok to true.
48 # XXX if it's a renewal and the renewal is not permitted, set
49 # $self->screen_msg("Item on Hold for Another User"); (or somesuch)
50 # XXX Set $self->ok(0) on any errors
53 syslog('LOG_DEBUG', "OILS: performing checkout...");
58 barcode => $self->{item}->id,
59 patron_barcode => $self->{patron}->id
62 my $resp = $U->simplereq(
64 'open-ils.circ.checkout.permit',
65 $self->{authtoken}, $args );
67 if( ref($resp) eq 'ARRAY' ) {
69 push( @e, $_->{textcode} ) for @$resp;
70 syslog('LOG_INFO', "OILS: Checkout permit failed with events: @e");
74 if( my $code = $U->event_code($resp) ) {
75 my $txt = $resp->{textcode};
76 syslog('LOG_INFO', "OILS: Checkout permit failed with event $code : $txt");
82 if( $key = $resp->{payload} ) {
83 syslog('LOG_INFO', "OILS: circ permit key => $key");
86 syslog('LOG_WARN', "OILS: Circ permit failed :\n" . Dumper($resp) );
90 # Now do the actual checkout
94 patron_barcode => $self->{patron}->id,
95 barcode => $self->{item}->id
98 $resp = $U->simplereq(
100 'open-ils.circ.checkout', $self->{authtoken}, $args );
102 # XXX Check for events
105 if( my $code = $U->event_code($resp) ) {
106 my $txt = $resp->{textcode};
107 syslog('LOG_INFO', "OILS: Checkout failed with event $code : $txt");
111 syslog('LOG_INFO', "OILS: Checkout succeeded");
113 my $circ = $resp->{payload}->{circ};
114 $self->{'due'} = $circ->due_date;