From 5f4fb1e31d9388ae5369cf37d0d3474328bbb33a Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Sun, 14 Sep 2014 12:34:39 +0300 Subject: [PATCH 6/6] Bug 12892 - Holds Waiting: not showing from check out screen TEST PLAN: 1. Create a reservation for a Borrower with pickup branch 2. Check-in the corresponding Item in the pickup branch and confirm the hold for the Borrower 3. Go to circ/circulation.pl for the Borrower and verify that the reservation is "Waiting for pickup" 4. In the Borrower -> Check Out -tab (circ/circulation.pl) on the right of the big "Checking out to borrowername" should be a notification about holds ready for pickup. --- Koha/Reserves.pm | 65 ++++++++++++++++++++ circ/circulation.pl | 3 + .../prog/en/modules/circ/circulation.tt | 33 +++++----- 3 files changed, 87 insertions(+), 14 deletions(-) diff --git a/Koha/Reserves.pm b/Koha/Reserves.pm index 6580a55..f317e4d 100644 --- a/Koha/Reserves.pm +++ b/Koha/Reserves.pm @@ -60,6 +60,71 @@ sub GetLastpickupdate { return $expiration; } +=head2 GetWaitingReserves + my $waitingReserves = GetWaitingReserves($borrowernumber); + +@PARAM1 Integer from koha.borrowers.borrowernumber +@RETURNS DBIx:: containing Reservation-objects. +=cut +sub GetWaitingReserves { + my ($borrowernumber) = @_; + + my $schema = Koha::Database->new()->schema(); + my $reserves_rs = $schema->resultset('Reserve')->search( + { -and => [ + borrowernumber => $borrowernumber, + found => 'W' + ] + }, + { + prefetch => { 'item' => 'biblio' }, + } + ); + + my $currentBranch = C4::Context->userenv->{branch}; + + my @waitingReserves; + while ( my $reserve = $reserves_rs->next() ) { + my %waitingReserveInfo; + + my $lastpickupdate = Koha::Reserves::GetLastpickupdate( $reserve ); + $lastpickupdate = C4::Dates->new($lastpickupdate->ymd(), 'iso')->output(); + + my $pickupBranchcode = $reserve->branchcode(); + my $pickupBranch; + if (ref $pickupBranchcode eq 'Koha::Schema::Result::Branch') { + $pickupBranch = $pickupBranchcode; + $pickupBranchcode = $pickupBranchcode->branchcode(); + } + + my $biblio = $reserve->biblio(); + if ($biblio) { #For some reason it is possible for a waiting hold to not have a biblio? + $waitingReserveInfo{title} = $biblio->title(); + $waitingReserveInfo{biblionumber} = $biblio->biblionumber(); + $waitingReserveInfo{author} = $biblio->author(); + } + else { + $waitingReserveInfo{title} = "<>"; + } + + $waitingReserveInfo{lastpickupdate} = $lastpickupdate; + + my $item = $reserve->item(); + if ($item) { + $waitingReserveInfo{itemcallnumber} = $reserve->item()->itemcallnumber(); + } + else { + $waitingReserveInfo{itemcallnumber} = "<>"; + } + + #$waitingReserveInfo{itemcallnumber} = $reserve->item()->itemcallnumber(); + $waitingReserveInfo{waitinghere} = 1 if $pickupBranchcode eq $currentBranch; + $waitingReserveInfo{waitingat} = $pickupBranch->branchname(); + + push @waitingReserves, \%waitingReserveInfo; + } + return \@waitingReserves; +} return 1; \ No newline at end of file diff --git a/circ/circulation.pl b/circ/circulation.pl index 8b4adee..2186504 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -43,6 +43,7 @@ use C4::Members::Attributes qw(GetBorrowerAttributes); use Koha::Borrower::Debarments qw(GetDebarments IsDebarred); use Koha::DateUtils; use Koha::Database; +use Koha::Reserves; use Date::Calc qw( Today @@ -378,6 +379,8 @@ if ($borrowernumber) { ->count( { borrowernumber => $borrowernumber } ) ); $template->param( adultborrower => 1 ) if ( $borrower->{'category_type'} eq 'A' ); + + $template->param( WaitingReserveLoop => Koha::Reserves::GetWaitingReserves($borrowernumber) ); } my @values; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index d000ceb..a452b62 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -616,20 +616,25 @@ No patron matched [% message %] - [% IF ( WaitingReserveLoop ) %] -
-

Holds waiting:

- [% FOREACH WaitingReserveLoo IN WaitingReserveLoop %] -
    -
  • [% WaitingReserveLoo.title |html %] ([% WaitingReserveLoo.itemtype %]), [% IF ( WaitingReserveLoo.author ) %]by [% WaitingReserveLoo.author %][% END %] [% IF ( WaitingReserveLoo.itemcallnumber ) %][[% WaitingReserveLoo.itemcallnumber %]] [% END %]Hold placed on [% WaitingReserveLoo.reservedate %]. - [% IF ( WaitingReserveLoo.waitingat ) %] -
    [% IF ( WaitingReserveLoo.waitinghere ) %][% ELSE %][% END %]Waiting at [% WaitingReserveLoo.waitingat %] - [% END %] -
  • -
- [% END %] -
- [% END %] + [% IF ( WaitingReserveLoop ) %] +
+

Holds waiting:

+ [% FOREACH WaitingReserveLoo IN WaitingReserveLoop %] +
    +
  • [% WaitingReserveLoo.title |html %] [% IF ( WaitingReserveLoo.author ) %] [% WaitingReserveLoo.author %][% END %] [% IF ( WaitingReserveLoo.itemcallnumber ) %][[% WaitingReserveLoo.itemcallnumber %]] [% END %] + [% IF ( WaitingReserveLoo.lastpickupdate ) %] + Last pickup date [% WaitingReserveLoo.lastpickupdate %] + [% END %] + [% IF ( WaitingReserveLoo.waitingat ) %] +
    [% IF ( WaitingReserveLoo.waitinghere ) %][% ELSE %][% END %] + Waiting at [% WaitingReserveLoo.waitingat %] + + [% END %] +
  • +
+ [% END %] +
+ [% END %] [% IF ( notes ) %]

Notes:

-- 1.7.9.5