- foreach my $impossible ( keys %$issuingimpossible ) {
- # do something here so we pass these errors
- $self->screen_msg($issuingimpossible->{$impossible});
- $noerror = 0;
- }
- foreach my $confirmation ( keys %$needsconfirmation ) {
- if ($confirmation eq 'RENEW_ISSUE'){
- if (!CanBookBeRenewed($borrower->{borrowernumber},$self->{item}->{itemnumber})){
- $noerror = 0;
- warn "cant renew $borrower->{borrowernumber} $self->{item}->{itemnumber}";
- }
- }
- else {
- $self->screen_msg($needsconfirmation->{$confirmation});
- $noerror = 0;
- }
- }
-
-
- if ($noerror){
- warn "can issue";
- # we can issue
- my $datedue = AddIssue( $borrower, $barcode, undef, 0 );
- $self->{'due'} = $datedue;
- $self->ok(1);
- }
- else {
- warn "cant issue";
- use Data::Dumper;
- warn Dumper $issuingimpossible;
- warn Dumper $needsconfirmation;
+ if (scalar keys %$issuingimpossible) {
+ foreach (keys %$issuingimpossible) {
+ # do something here so we pass these errors
+ $self->screen_msg($_ . ': ' . $issuingimpossible->{$_});
+ $noerror = 0;
+ }
+ } else {
+ foreach my $confirmation (keys %{$needsconfirmation}) {
+ if ($confirmation eq 'RENEW_ISSUE'){
+ $self->screen_msg("Item already checked out to you: renewing item.");
+ } elsif ($confirmation eq 'RESERVED' or $confirmation eq 'RESERVE_WAITING') {
+ my $x = $self->{item}->available($patron_barcode);
+ if ($x) {
+ $self->screen_msg("Item was reserved for you.");
+ } else {
+ $self->screen_msg("Item is reserved for another patron upon return.");
+ # $noerror = 0;
+ }
+ } elsif ($confirmation eq 'ISSUED_TO_ANOTHER') {
+ $self->screen_msg("Item already checked out to another patron. Please return item for check-in.");
+ $noerror = 0;
+ } elsif ($confirmation eq 'DEBT') { # don't do anything, it's the minor debt, and alarms fire elsewhere
+ } elsif ($confirmation eq 'HIGHHOLDS') {
+ $overridden_duedate = $needsconfirmation->{$confirmation}->{returndate};
+ $self->screen_msg('Loan period reduced for high-demand item');
+ } else {
+ $self->screen_msg($needsconfirmation->{$confirmation});
+ $noerror = 0;
+ }
+ }
+ }
+ my $itemnumber = $self->{item}->{itemnumber};
+ foreach (@$shelf) {
+ $debug and warn "shelf has ($_->{itemnumber} for $_->{borrowernumber}). this is ($itemnumber, $self->{patron}->{borrowernumber})";
+ ($_->{itemnumber} eq $itemnumber) or next; # skip it if not this item
+ ($_->{borrowernumber} == $self->{patron}->{borrowernumber}) and last;
+ # if item was waiting for this patron, we're done. AddIssue takes care of the "W" hold.
+ $debug and warn "Item is on hold shelf for another patron.";
+ $self->screen_msg("Item is on hold shelf for another patron.");
+ $noerror = 0;
+ }
+ unless ($noerror) {
+ $debug and warn "cannot issue: " . Dumper($issuingimpossible) . "\n" . Dumper($needsconfirmation);