2 # An object to handle checkout status
5 package ILS::Transaction::Checkout;
10 use POSIX qw(strftime);
11 use Sys::Syslog qw(syslog);
22 use vars qw($VERSION @ISA $debug);
26 @ISA = qw(ILS::Transaction);
30 # Most fields are handled by the Transaction superclass
32 security_inhibit => 0,
39 my $self = $class->SUPER::new();
41 foreach $element (keys %fields) {
42 $self->{_permitted}->{$element} = $fields{$element};
44 @{$self}{keys %fields} = values %fields;
45 # $self->{'due'} = time() + (60*60*24*14); # two weeks hence
46 $debug and warn "new ILS::Transaction::Checkout : " . Dumper $self;
47 return bless $self, $class;
52 syslog('LOG_DEBUG', "ILS::Transaction::Checkout performing checkout...");
53 my $barcode = $self->{item}->id;
54 my $patron_barcode = $self->{patron}->id;
55 $debug and warn "do_checkout: patron (" . $patron_barcode . ")";
56 my $borrower = GetMember( $patron_barcode, 'cardnumber' );
57 $debug and warn "do_checkout borrower: . " . Dumper $borrower;
58 my ($issuingimpossible,$needsconfirmation) = CanBookBeIssued( $borrower, $barcode );
60 foreach ( keys %$issuingimpossible ) {
61 # do something here so we pass these errors
62 $self->screen_msg($_ . ': ' . $issuingimpossible->{$_});
65 foreach my $confirmation ( keys %$needsconfirmation ) {
66 if ($confirmation eq 'RENEW_ISSUE'){
67 $self->screen_msg("Item already checked out to you: renewing item.");
68 } elsif ($confirmation eq 'RESERVED' or $confirmation eq 'RESERVE_WAITING') {
69 my $x = $self->{item}->available($patron_barcode);
71 $self->screen_msg("Item was reserved for you.");
73 $self->screen_msg("Item is reserved for another patron.");
76 } elsif ($confirmation eq 'ISSUED_TO_ANOTHER') {
77 $self->screen_msg("Item already checked out to another patron. Please return item for check-in.");
79 } elsif ($confirmation eq 'DEBT') { # don't do anything, it's the minor debt, and alarms fire elsewhere
81 $self->screen_msg($needsconfirmation->{$confirmation});
86 warn "cannot issue: " . Dumper($issuingimpossible) . "\n" . Dumper($needsconfirmation);
91 $debug and warn "do_checkout: calling AddIssue(\$borrower,$barcode, undef, 0)\n"
92 # . "w/ \$borrower: " . Dumper($borrower)
93 . "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv);
94 $self->{'due'} = AddIssue( $borrower, $barcode, undef, 0 );