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,
33 warn 'ARGS = ' . Dumper(\@_);
35 my $self = $class->SUPER::new(@_);
39 foreach $element (keys %fields) {
40 $self->{_permitted}->{$element} = $fields{$element};
43 @{$self}{keys %fields} = values %fields;
45 return bless $self, $class;
49 # if this item is already checked out to the requested patron,
50 # renew the item and set $self->renew_ok to true.
51 # XXX if it's a renewal and the renewal is not permitted, set
52 # $self->screen_msg("Item on Hold for Another User"); (or somesuch)
53 # XXX Set $self->ok(0) on any errors
56 syslog('LOG_DEBUG', "OpenILS: performing checkout...");
59 barcode => $self->{item}->id,
60 patron_barcode => $self->{patron}->id
63 my $resp = $U->simplereq(
65 'open-ils.circ.checkout.permit',
66 $self->{authtoken}, $args );
70 if( ref($resp) eq 'HASH' and $key = $resp->{payload} ) {
71 syslog('LOG_INFO', "OpenILS: circ permit key => $key");
74 syslog('LOG_INFO', "OpenILS: Circ permit failed :\n" . Dumper($resp) );
81 patron_barcode => $self->{patron}->id,
82 barcode => $self->{item}->id
85 $resp = $U->simplereq(
87 'open-ils.circ.checkout', $self->{authtoken}, $args );
89 # XXX Check for events
91 syslog('LOG_INFO', "OpenILS: Checkout succeeded");
92 my $evt = $resp->{ilsevent};
93 my $circ = $resp->{payload}->{circ};
95 if(!$circ or $evt ne 0) {
97 warn 'CHECKOUT RESPONSE: ' . Dumper($resp) . "\n";
101 $self->{'due'} = $circ->due_date;