2 # An object to handle checkout status
5 package ILS::Transaction::Checkout;
10 use POSIX qw(strftime);
11 use Sys::Syslog qw(syslog);
23 use vars qw($VERSION @ISA $debug);
27 @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 # my $borrower = $self->{patron};
58 # my $borrower = GetMemberDetails(undef, $patron_barcode);
59 my $borrower = $self->{patron}->getmemberdetails_object();
60 $debug and warn "do_checkout borrower: . " . Dumper $borrower;
61 my ($issuingimpossible,$needsconfirmation) = CanBookBeIssued( $borrower, $barcode );
63 foreach ( keys %$issuingimpossible ) {
64 # do something here so we pass these errors
65 $self->screen_msg($issuingimpossible->{$_});
68 foreach my $confirmation ( keys %$needsconfirmation ) {
69 if ($confirmation eq 'RENEW_ISSUE'){
70 my ($renewokay,$renewerror)= CanBookBeRenewed($borrower->{borrowernumber},$self->{item}->{itemnumber});
73 warn "cannot renew $borrower->{borrowernumber} $self->{item}->{itemnumber} $renewerror";
76 $self->screen_msg($needsconfirmation->{$confirmation});
81 warn "cannot issue: " . Dumper $issuingimpossible . "\n" . $needsconfirmation;
86 $debug and warn "do_checkout: calling AddIssue(\$borrower,$barcode, undef, 0)\n"
87 # . "w/ \$borrower: " . Dumper($borrower)
88 . "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv);
89 my $c4due = AddIssue( $borrower, $barcode, undef, 0 );
90 my $due = $c4due->output('iso') || undef;
91 $debug and warn "Item due: $due";
92 $self->{'due'} = $due;
93 $self->{item}->due_date($due);