From 71686eb7474d5f104eb5d735bc75ee5561dcfa7e Mon Sep 17 00:00:00 2001 From: Hayley Mapley Date: Tue, 20 Aug 2019 05:02:14 +0000 Subject: [PATCH] Bug 8367: Fixes to make the workflow of master fit, including display of lastpickupdate Changed circ/waitingreserves.pl to correctly display lastpickupdate in Circulation>Holds awaiting pickup. Changed includes/holds-table.inc to display lastpickupdate in opac-user.pl in Holds tab. Sponsored-by: Brimbank District Council Authored-by: Hayley Mapley and Alex Buckley (Catalyst IT) --- C4/Circulation.pm | 1 + C4/Reserves.pm | 9 ++-- circ/waitingreserves.pl | 50 +++------------------- .../bootstrap/en/includes/holds-table.inc | 2 +- 4 files changed, 12 insertions(+), 50 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 44f94e7fec7..23fb6ec5b7d 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2058,6 +2058,7 @@ sub AddReturn { # if we don't have a reserve with the status W, we launch the Checkreserves routine my ($resfound, $resrec); my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds + ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn ); if ($resfound) { $resrec->{'ResFound'} = $resfound; diff --git a/C4/Reserves.pm b/C4/Reserves.pm index bfecb16d4c8..f6b3eb01eae 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -186,7 +186,7 @@ sub AddReserve { } my ($waitingdate, $lastpickupdate); - my $item = C4::Items::GetItem( $checkitem ); + my $item = Koha::Items->find( $checkitem ); #FIXME Prevent bad calls # If the reserv had the waiting status, we had the value of the resdate if ( $found eq 'W' ) { $waitingdate = $resdate; @@ -897,8 +897,9 @@ sub CheckReserves { my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$item->effective_itemtype); next if ($branchitemrule->{'holdallowed'} == 0); next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $patron->branchcode)); - my $hold_fulfillment_policy = $branchitemrule->{hold_fulfillment_policy}; - next if ( ($branchitemrule->{hold_fulfillment_policy} ne 'any') && ($res->{branchcode} ne $item->$hold_fulfillment_policy) ); + my $hold_fulfillment_policy = $branchitemrule->{'hold_fulfillment_policy'}; + + next if ( ($branchitemrule->{'hold_fulfillment_policy'} ne 'any') && ($res->{branchcode} ne $item->$hold_fulfillment_policy) ); next unless $item->can_be_transferred( { to => scalar Koha::Libraries->find( $res->{branchcode} ) } ); $priority = $res->{'priority'}; $highest = $res; @@ -1198,7 +1199,7 @@ sub ModReserveAffect { $hold->itemnumber($itemnumber); $hold->set_waiting($transferToDo); - my $item = C4::Items::GetItem( $itemnumber ); + my $item = Koha::Items->find( $itemnumber ); my $borrower = Koha::Patrons->find( $borrowernumber ); $borrower = $borrower->unblessed; my $lastpickupdate = GetLastPickupDate( $hold, $item, $borrower ); diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl index 3e54bbef97d..3c5ac951552 100755 --- a/circ/waitingreserves.pl +++ b/circ/waitingreserves.pl @@ -89,61 +89,21 @@ my $holds = Koha::Holds->waiting->search({ priority => 0, ( $all_branches ? () : # get reserves for the branch we are logged into, or for all branches my $today = dt_from_string; -my $max_pickup_delay = C4::Context->preference('ReservesMaxPickUpDelay'); while ( my $hold = $holds->next ) { next unless ($hold->waitingdate && $hold->waitingdate ne '0000-00-00'); - my $item = $hold->item; - my $patron = $hold->borrower; - my $biblio = $item->biblio; - my $holdingbranch = $item->holdingbranch; - my $homebranch = $item->homebranch; - my %getreserv = ( - title => $biblio->title, - itemnumber => $item->itemnumber, - waitingdate => $hold->waitingdate, - reservedate => $hold->reservedate, - borrowernumber => $patron->borrowernumber, - biblionumber => $biblio->biblionumber, - barcode => $item->barcode, - homebranch => $homebranch, - holdingbranch => $item->holdingbranch, - itemcallnumber => $item->itemcallnumber, - enumchron => $item->enumchron, - copynumber => $item->copynumber, - borrowername => $patron->surname, # FIXME Let's send $patron to the template - borrowerfirstname => $patron->firstname, - borrowerphone => $patron->phone, - lastpickupdate => $hold->lastpickupdate, - ); - - my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); - $getreserv{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description? - $getreserv{'subtitle'} = GetRecordValue( - 'subtitle', - GetMarcBiblio({ biblionumber => $biblio->biblionumber }), - $biblio->frameworkcode); - if ( $homebranch ne $holdingbranch ) { - $getreserv{'dotransfer'} = 1; - } - - $getreserv{patron} = $patron; - warn $getreserv{'waitingdate'}; - warn $getreserv{'lastpickupdate'}; - if ( $getreserv{'waitingdate'} ) { - my $lastpickupdate = dt_from_string($getreserv{'lastpickupdate'}); + if ( $hold->waitingdate ) { + my $lastpickupdate = dt_from_string($hold->lastpickupdate); if ( DateTime->compare( $today, $lastpickupdate ) == 1 ) { if ($cancelall) { - my $res = cancel( $item->itemnumber, $patron->borrowernumber, $item->holdingbranch, $homebranch, !$transfer_when_cancel_all ); + my $res = cancel( $hold->item->itemnumber, $hold->borrowernumber, $hold->item->holdingbranch, $hold->item->homebranch, !$transfer_when_cancel_all ); push @cancel_result, $res if $res; next; } else { - push @overloop, \%getreserv; - $overcount++; + push @over_loop, $hold; } }else{ - push @reservloop, \%getreserv; - $reservcount++; + push @reserve_loop, $hold; } } } diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc index 4f2ba9ede5b..6b03076ccf7 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc @@ -107,7 +107,7 @@ [% IF ( HOLD.found ) %] Item waiting at [% HOLD.branch.branchname | html %] [% IF ( HOLD.waitingdate ) %] - since [% HOLD.waitingdate | $KohaDates %] until [% RESERVE.lastpickupdate | $KohaDates %] + since [% HOLD.waitingdate | $KohaDates %] until [% HOLD.lastpickupdate | $KohaDates %] [% END %] [% ELSE %] -- 2.11.0