X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FReserves.pm;h=22a9ecb4381628f420db7b255694c87cbbd8f440;hb=ef6bc21b2c4ebe04f6d22d081e447f6bb2955029;hp=abefa2daa5d0add0fff5aced043abc4f6806d2b1;hpb=ebf4350735da7ea365f3b5b72410f6810a9182b8;p=srvgit diff --git a/C4/Reserves.pm b/C4/Reserves.pm index abefa2daa5..22a9ecb438 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -136,6 +136,8 @@ BEGIN { &SuspendAll &GetReservesControlBranch + + IsItemOnHoldAndFound ); @EXPORT_OK = qw( MergeHolds ); } @@ -205,6 +207,7 @@ sub AddReserve { $const, $priority, $notes, $checkitem, $found, $waitingdate, $expdate ); + my $reserve_id = $sth->{mysql_insertid}; # Send e-mail to librarian if syspref is active if(C4::Context->preference("emailLibrarianWhenHoldIsPlaced")){ @@ -248,7 +251,7 @@ sub AddReserve { $sth->execute($borrowernumber, $biblionumber, $resdate, $_); } - return; # FIXME: why not have a useful return value? + return $reserve_id; } =head2 GetReserve @@ -1306,7 +1309,7 @@ sub ModReserveFill { # now fix the priority on the others (if the priority wasn't # already sorted!).... unless ( $priority == 0 ) { - _FixPriority({ reserve_id => $reserve_id }); + _FixPriority({ reserve_id => $reserve_id, biblionumber => $biblionumber }); } } @@ -2051,10 +2054,12 @@ sub _koha_notify_reserve { }; while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) { - if ( ($mtt eq 'email' and not $to_address) or ($mtt eq 'sms' and not $borrower->{smsalertnumber}) ) { - # email or sms is requested but not exist - next; - } + next if ( + ( $mtt eq 'email' and not $to_address ) # No email address + or ( $mtt eq 'sms' and not $borrower->{smsalertnumber} ) # No SMS number + or ( $mtt eq 'phone' and C4::Context->preference('TalkingTechItivaPhoneNotification') ) # Notice is handled by TalkingTech_itiva_outbound.pl + ); + &$send_notification($mtt, $letter_code); $notification_sent++; } @@ -2411,6 +2416,30 @@ sub CalculatePriority { return @row ? $row[0]+1 : 1; } +=head2 IsItemOnHoldAndFound + + my $bool = IsItemFoundHold( $itemnumber ); + + Returns true if the item is currently on hold + and that hold has a non-null found status ( W, T, etc. ) + +=cut + +sub IsItemOnHoldAndFound { + my ($itemnumber) = @_; + + my $rs = Koha::Database->new()->schema()->resultset('Reserve'); + + my $found = $rs->count( + { + itemnumber => $itemnumber, + found => { '!=' => undef } + } + ); + + return $found; +} + =head1 AUTHOR Koha Development Team