Merge branch 'bug_9367' into 3.12-master
This commit is contained in:
commit
a0abb3b5f3
9 changed files with 50 additions and 39 deletions
11
C4/Biblio.pm
11
C4/Biblio.pm
|
@ -785,20 +785,11 @@ sub GetBiblioData {
|
|||
my ($bibnum) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
# my $query = C4::Context->preference('item-level_itypes') ?
|
||||
# " SELECT * , biblioitems.notes AS bnotes, biblio.notes
|
||||
# FROM biblio
|
||||
# LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber
|
||||
# WHERE biblio.biblionumber = ?
|
||||
# AND biblioitems.biblionumber = biblio.biblionumber
|
||||
#";
|
||||
|
||||
my $query = " SELECT * , biblioitems.notes AS bnotes, itemtypes.notforloan as bi_notforloan, biblio.notes
|
||||
FROM biblio
|
||||
LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber
|
||||
LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype
|
||||
WHERE biblio.biblionumber = ?
|
||||
AND biblioitems.biblionumber = biblio.biblionumber ";
|
||||
WHERE biblio.biblionumber = ?";
|
||||
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute($bibnum);
|
||||
|
|
|
@ -2473,7 +2473,6 @@ sub CanBookBeRenewed {
|
|||
|
||||
$sthcount->execute( $borrowernumber, $itemnumber );
|
||||
if ( my $data1 = $sthcount->fetchrow_hashref ) {
|
||||
|
||||
if ( ( $data1->{renewalsallowed} && $data1->{renewalsallowed} > $data1->{renewals} ) || $override_limit ) {
|
||||
$renewokay = 1;
|
||||
}
|
||||
|
@ -2481,12 +2480,11 @@ sub CanBookBeRenewed {
|
|||
$error = "too_many";
|
||||
}
|
||||
|
||||
my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves($itemnumber);
|
||||
if ($resfound) {
|
||||
my $resstatus = C4::Reserves::GetReserveStatus($itemnumber);
|
||||
if ( $resstatus eq "Waiting" or $resstatus eq "Reserved" ) {
|
||||
$renewokay = 0;
|
||||
$error="on_reserve"
|
||||
$error = "on_reserve";
|
||||
}
|
||||
|
||||
}
|
||||
return ($renewokay,$error);
|
||||
}
|
||||
|
|
|
@ -735,16 +735,40 @@ sub GetReservesForBranch {
|
|||
return (@transreserv);
|
||||
}
|
||||
|
||||
=head2 GetReserveStatus
|
||||
|
||||
$reservestatus = GetReserveStatus($itemnumber, $biblionumber);
|
||||
|
||||
Take an itemnumber or a biblionumber and return the status of the reserve places on it.
|
||||
If several reserves exist, the reserve with the lower priority is given.
|
||||
|
||||
=cut
|
||||
|
||||
sub GetReserveStatus {
|
||||
my ($itemnumber) = @_;
|
||||
my ($itemnumber, $biblionumber) = @_;
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
my $itemstatus = $dbh->prepare("SELECT found FROM reserves WHERE itemnumber = ?");
|
||||
my ($sth, $found, $priority);
|
||||
if ( $itemnumber ) {
|
||||
$sth = $dbh->prepare("SELECT found, priority FROM reserves WHERE itemnumber = ? order by priority LIMIT 1");
|
||||
$sth->execute($itemnumber);
|
||||
($found, $priority) = $sth->fetchrow_array;
|
||||
}
|
||||
|
||||
$itemstatus->execute($itemnumber);
|
||||
my ($found) = $itemstatus->fetchrow_array;
|
||||
return $found;
|
||||
if ( $biblionumber and not defined $found and not defined $priority ) {
|
||||
$sth = $dbh->prepare("SELECT found, priority FROM reserves WHERE biblionumber = ? order by priority LIMIT 1");
|
||||
$sth->execute($biblionumber);
|
||||
($found, $priority) = $sth->fetchrow_array;
|
||||
}
|
||||
|
||||
if(defined $found) {
|
||||
return 'Waiting' if $found eq 'W' and $priority == 0;
|
||||
return 'Finished' if $found eq 'F';
|
||||
return 'Reserved' if $priority > 0;
|
||||
}
|
||||
return '';
|
||||
#empty string here will remove need for checking undef, or less log lines
|
||||
}
|
||||
|
||||
=head2 CheckReserves
|
||||
|
@ -1441,7 +1465,7 @@ sub IsAvailableForItemLevelRequest {
|
|||
if (C4::Context->preference('AllowOnShelfHolds')) {
|
||||
return $available_per_item;
|
||||
} else {
|
||||
return ($available_per_item and ($item->{onloan} or GetReserveStatus($itemnumber) eq "W"));
|
||||
return ($available_per_item and ($item->{onloan} or GetReserveStatus($itemnumber) eq "Waiting"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ use C4::Dates qw(format_date);
|
|||
use C4::Members qw(GetHideLostItemsPreference);
|
||||
use C4::XSLT;
|
||||
use C4::Branch;
|
||||
use C4::Reserves; # CheckReserves
|
||||
use C4::Reserves; # GetReserveStatus
|
||||
use C4::Debug;
|
||||
use C4::Charset;
|
||||
use YAML;
|
||||
|
@ -1853,7 +1853,6 @@ sub searchResults {
|
|||
|
||||
# is item on the reserve shelf?
|
||||
my $reservestatus = '';
|
||||
my $reserveitem;
|
||||
|
||||
unless ($item->{wthdrawn}
|
||||
|| $item->{itemlost}
|
||||
|
@ -1874,7 +1873,7 @@ sub searchResults {
|
|||
# should map transit status to record indexed in Zebra.
|
||||
#
|
||||
($transfertwhen, $transfertfrom, $transfertto) = C4::Circulation::GetTransfers($item->{itemnumber});
|
||||
($reservestatus, $reserveitem, undef) = C4::Reserves::CheckReserves($item->{itemnumber});
|
||||
$reservestatus = C4::Reserves::GetReserveStatus( $item->{itemnumber}, $oldbiblio->{biblionumber} );
|
||||
}
|
||||
|
||||
# item is withdrawn, lost, damaged, not for loan, reserved or in transit
|
||||
|
|
|
@ -247,7 +247,7 @@ sub buildKohaItemsNamespace {
|
|||
|
||||
my ( $transfertwhen, $transfertfrom, $transfertto ) = C4::Circulation::GetTransfers($item->{itemnumber});
|
||||
|
||||
my ( $reservestatus, $reserveitem, undef ) = C4::Reserves::CheckReserves($item->{itemnumber});
|
||||
my $reservestatus = C4::Reserves::GetReserveStatus( $item->{itemnumber} );
|
||||
|
||||
if ( $itemtypes->{ $item->{itype} }->{notforloan} || $item->{notforloan} || $item->{onloan} || $item->{wthdrawn} || $item->{itemlost} || $item->{damaged} ||
|
||||
(defined $transfertwhen && $transfertwhen ne '') || $item->{itemnotforloan} || (defined $reservestatus && $reservestatus eq "Waiting") ){
|
||||
|
|
|
@ -448,10 +448,10 @@ sub build_issue_data {
|
|||
$it->{'borrowernumber'},$it->{'itemnumber'}
|
||||
);
|
||||
$it->{"renew_error_${can_renew_error}"} = 1 if defined $can_renew_error;
|
||||
my ( $restype, $reserves, undef ) = CheckReserves( $it->{'itemnumber'} );
|
||||
my $restype = C4::Reserves::GetReserveStatus( $it->{'itemnumber'} );
|
||||
$it->{'can_renew'} = $can_renew;
|
||||
$it->{'can_confirm'} = !$can_renew && !$restype;
|
||||
$it->{'renew_error'} = $restype;
|
||||
$it->{'renew_error'} = ( $restype eq "Waiting" or $restype eq "Reserved" ) ? 1 : 0;
|
||||
$it->{'checkoutdate'} = C4::Dates->new($it->{'issuedate'},'iso')->output('syspref');
|
||||
$it->{'issuingbranchname'} = GetBranchName($it->{'branchcode'});
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ use C4::Circulation;
|
|||
use C4::Koha;
|
||||
use C4::Letters;
|
||||
use C4::Biblio;
|
||||
use C4::Reserves;
|
||||
use C4::Branch; # GetBranchName
|
||||
use C4::Overdues qw/CheckBorrowerDebarred/;
|
||||
use C4::Form::MessagingPreferences;
|
||||
|
|
|
@ -554,7 +554,7 @@ for my $itm (@items) {
|
|||
$itm->{'lostimageurl'} = $lostimageinfo->{ 'imageurl' };
|
||||
$itm->{'lostimagelabel'} = $lostimageinfo->{ 'label' };
|
||||
}
|
||||
my ($reserve_status) = C4::Reserves::CheckReserves($itm->{itemnumber});
|
||||
my $reserve_status = C4::Reserves::GetReserveStatus($itm->{itemnumber});
|
||||
if( $reserve_status eq "Waiting"){ $itm->{'waiting'} = 1; }
|
||||
if( $reserve_status eq "Reserved"){ $itm->{'onhold'} = 1; }
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ my $issues = GetPendingIssues($borrowernumber);
|
|||
if ($issues){
|
||||
foreach my $issue ( sort { $b->{date_due}->datetime() cmp $a->{date_due}->datetime() } @{$issues} ) {
|
||||
# check for reserves
|
||||
my ( $restype, $res, undef ) = CheckReserves( $issue->{'itemnumber'} );
|
||||
my $restype = GetReserveStatus( $issue->{'itemnumber'} );
|
||||
if ( $restype ) {
|
||||
$issue->{'reserved'} = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue