@@ -, +, @@ waiting hold line. --- Koha/Biblio.pm | 13 +++++ Koha/Hold.pm | 25 ++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 50 ++++++++++++-------- opac/opac-user.pl | 18 +++++-- 4 files changed, 80 insertions(+), 26 deletions(-) --- a/Koha/Biblio.pm +++ a/Koha/Biblio.pm @@ -21,6 +21,8 @@ use Modern::Perl; use Carp; +use C4::Biblio qw( GetRecordValue GetMarcBiblio GetFrameworkCode ); + use Koha::Database; use base qw(Koha::Object); @@ -35,6 +37,17 @@ Koha::Biblio - Koha Biblio Object class =cut +=head3 subtitle + +=cut + +sub subtitle { + my ( $self ) = @_; + + return GetRecordValue( 'subtitle', GetMarcBiblio( $self->id() ), GetFrameworkCode( $self->id() ) ); +} + + =head3 type =cut --- a/Koha/Hold.pm +++ a/Koha/Hold.pm @@ -91,6 +91,19 @@ sub is_waiting { return $self->found() eq 'W'; } +=head3 is_cancelable + +Returns true if hold is a cancelable hold + +=cut + +sub is_cancelable { + my ($self) = @_; + + return ( $self->is_waiting() && !$self->is_found() ) + || ( !$self->is_waiting() && !$self->is_in_transit() ); +} + =head3 is_in_transit Returns true if hold is a in_transit hold @@ -104,6 +117,18 @@ sub is_in_transit { return $self->found() eq 'T'; } +=head3 is_at_destination + +Returns true if hold is a in_transit hold + +=cut + +sub is_at_destination { + my ($self) = @_; + + return $self->is_waiting() && ( $self->branchcode() eq $self->item()->holdingbranch() ); +} + =head3 biblio Returns the related Koha::Biblio object for this hold --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -511,9 +511,9 @@ [% FOREACH RESERVE IN RESERVES %] - [% IF ( RESERVE.wait ) %] - [% IF ( RESERVE.atdestination ) %] - [% IF ( RESERVE.found ) %] + [% IF ( RESERVE.is_waiting ) %] + [% IF ( RESERVE.is_at_destination ) %] + [% IF ( RESERVE.is_found ) %] [% ELSE %] @@ -525,8 +525,8 @@ [% END %] - [% RESERVE.reserves_title %] [% FOREACH subtitl IN RESERVE.subtitle %] [% subtitl.subfield %][% END %] - [% RESERVE.author %] + [% RESERVE.biblio.title %] [% FOREACH subtitl IN RESERVE.biblio.subtitle %] [% subtitl.subfield %][% END %] + [% RESERVE.biblio.author %] @@ -535,19 +535,23 @@ - [% IF ( RESERVE.expirationdate ) %] - + [% IF ! RESERVE.found %] + [% IF ( RESERVE.expirationdate ) %] + + Expiration: + [% RESERVE.expirationdate | $KohaDates %] + + [% ELSE %] Expiration: - [% RESERVE.expirationdate | $KohaDates %] - + Never expires + [% END %] [% ELSE %] - Expiration: - Never expires + - [% END %] Pick up location: - [% RESERVE.branch %] + [% RESERVE.branch.branchname %] [% IF ( showpriority ) %] @@ -557,11 +561,17 @@ [% END %] Status: - [% IF ( RESERVE.wait ) %] - [% IF ( RESERVE.atdestination ) %] + [% IF ( RESERVE.is_waiting ) %] + [% IF ( RESERVE.is_at_destination ) %] [% IF ( RESERVE.found ) %] - Item waiting at [% RESERVE.wbrname %][% IF ( RESERVE.waitingdate ) %] since [% RESERVE.waitingdate | $KohaDates %][% END %] - + Item waiting at [% RESERVE.branch.branchname %] + [% IF ( RESERVE.waitingdate ) %] + since [% RESERVE.waitingdate | $KohaDates %] + [% IF RESERVE.waiting_expires_on %] + until [% RESERVE.waiting_expires_on | $KohaDates %] + [% END %] + [% END %] + [% ELSE %] Item waiting to be pulled from [% RESERVE.wbrname %] [% END %] @@ -569,7 +579,7 @@ Item in transit to [% RESERVE.wbrname %] [% END %] [% ELSE %] - [% IF ( RESERVE.intransit ) %] + [% IF ( RESERVE.is_in_transit ) %] Item in transit from [% RESERVE.frombranch %] since [% RESERVE.datesent | $KohaDates %] [% ELSIF ( RESERVE.suspend ) %] @@ -581,7 +591,7 @@ [% IF SuspendHoldsOpac %] - [% IF ( RESERVE.cancelable ) %] + [% IF ( RESERVE.is_cancelable ) %] [% IF RESERVE.suspend %]
@@ -622,11 +632,11 @@
[% END # / IF AutoResumeSuspendedHolds %] [% END # / IF RESERVE.suspend %] - [% END # / IF ( RESERVE.cancelable )%] + [% END # / IF ( RESERVE.is_cancelable )%] [% END # / IF SuspendHoldsOpac %] - [% IF ( RESERVE.cancelable ) %] + [% IF ( RESERVE.is_cancelable ) %]
--- a/opac/opac-user.pl +++ a/opac/opac-user.pl @@ -36,6 +36,7 @@ use C4::Letters; use C4::Branch; # GetBranches use Koha::DateUtils; use Koha::Borrower::Debarments qw(IsDebarred); +use Koha::Holds; use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE'; @@ -277,14 +278,17 @@ for my $branch_hash ( sort keys %{$branches} ) { $template->param( branchloop => \@branch_loop ); # now the reserved items.... -my @reserves = GetReservesFromBorrowernumber( $borrowernumber ); +my $reserves = Koha::Holds->search( { borrowernumber => $borrowernumber } ); +=head1 foreach my $res (@reserves) { + my $hold = Koha::Holds->find( $res->{reserve_id} ); if ( $res->{'expirationdate'} eq '0000-00-00' ) { $res->{'expirationdate'} = ''; } $res->{'subtitle'} = GetRecordValue('subtitle', GetMarcBiblio($res->{'biblionumber'}), GetFrameworkCode($res->{'biblionumber'})); $res->{'waiting'} = 1 if $res->{'found'} eq 'W'; + $res->{'waiting_since'} = $res->{'branch'} = $branches->{ $res->{'branchcode'} }->{'branchname'}; my $biblioData = GetBiblioData($res->{'biblionumber'}); $res->{'reserves_title'} = $biblioData->{'title'}; @@ -295,15 +299,17 @@ foreach my $res (@reserves) { } $res->{'suspend_until'} = C4::Dates->new( $res->{'suspend_until'}, "iso")->output("syspref") if ( $res->{'suspend_until'} ); } +=cut # use Data::Dumper; # warn Dumper(@reserves); -$template->param( RESERVES => \@reserves ); -$template->param( reserves_count => $#reserves+1 ); -$template->param( showpriority=>$show_priority ); +$template->param( RESERVES => $reserves ); +$template->param( reserves_count => $reserves->count() ); +$template->param( showpriority => $show_priority ); my @waiting; +=head1 my $wcount = 0; foreach my $res (@reserves) { if ( $res->{'itemnumber'} ) { @@ -345,8 +351,9 @@ foreach my $res (@reserves) { $res->{'cancelable'} = 1 if ($res->{wait} and not $res->{found}) or (not $res->{wait} and not $res->{intransit}); } +=cut -$template->param( WAITING => \@waiting ); +$template->param( WAITING => $reserves->waiting() ); # current alert subscriptions my $alerts = getalert($borrowernumber); @@ -384,7 +391,6 @@ if ( $borr->{'opacnote'} ) { $template->param( bor_messages_loop => GetMessages( $borrowernumber, 'B', 'NONE' ), - waiting_count => $wcount, patronupdate => $patronupdate, OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"), userview => 1, --