@@ -, +, @@ cancelled in OPAC --- Koha/Holds.pm | 15 +++++++++++++++ .../bootstrap/en/includes/holds-table.inc | 4 +--- .../bootstrap/en/modules/opac-holdshistory.tt | 6 +++++- opac/opac-user.pl | 2 +- t/db_dependent/Koha/Holds.t | 13 +++++++++++-- 5 files changed, 33 insertions(+), 7 deletions(-) --- a/Koha/Holds.pm +++ a/Koha/Holds.pm @@ -163,6 +163,21 @@ sub filter_by_has_cancellation_requests { { join => 'cancellation_requests' } ); } +=head3 filter_out_has_cancellation_requests + + my $holds_without_cancellation_requests = $holds->filter_out_has_cancellation_requests; + +Returns a filtered resultset without holds with cancellation requests. + +=cut + +sub filter_out_has_cancellation_requests { + my ($self) = @_; + + return $self->search( { 'hold_cancellation_request_id' => { '=' => undef } }, + { join => 'cancellation_requests' } ); +} + =head2 Internal methods =head3 _type --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc +++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc @@ -156,14 +156,12 @@ - [% ELSIF HOLD.cancellation_requests.count > 0 %] - [% ELSIF HOLD.is_waiting && HOLD.cancellation_requestable_from_opac %]
- +
[% END %] --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt @@ -153,7 +153,11 @@ [% ELSIF hold.cancellationdate %] Cancelled [% ELSIF hold.found == 'W' %] - Waiting + [% IF hold.cancellation_requests.count == 0 %] + Waiting + [% ELSE %] + Cancelled + [% END %] [% ELSIF hold.found == 'T' %] In transit [% ELSE %] --- a/opac/opac-user.pl +++ a/opac/opac-user.pl @@ -326,7 +326,7 @@ if ($show_barcode) { $template->param( show_barcode => 1 ) if $show_barcode; # now the reserved items.... -my $reserves = Koha::Holds->search( { borrowernumber => $borrowernumber } ); +my $reserves = $patron->holds->filter_out_has_cancellation_requests; $template->param( RESERVES => $reserves, --- a/t/db_dependent/Koha/Holds.t +++ a/t/db_dependent/Koha/Holds.t @@ -644,9 +644,9 @@ subtest 'set_waiting+patron_expiration_date' => sub { $schema->storage->txn_rollback; -subtest 'filter_by_has_cancellation_requests() tests' => sub { +subtest 'filter_by_has_cancellation_requests() and filter_out_has_cancellation_requests() tests' => sub { - plan tests => 4; + plan tests => 7; $schema->storage->txn_begin; @@ -699,6 +699,10 @@ subtest 'filter_by_has_cancellation_requests() tests' => sub { is( $filtered_rs->count, 0 ); + my $filtered_out_rs = $rs->filter_out_has_cancellation_requests; + + is( $filtered_out_rs->count, 3 ); + $hold_2->add_cancellation_request; $filtered_rs = $rs->filter_by_has_cancellation_requests; @@ -706,5 +710,10 @@ subtest 'filter_by_has_cancellation_requests() tests' => sub { is( $filtered_rs->count, 1 ); is( $filtered_rs->next->id, $hold_2->id ); + $filtered_out_rs = $rs->filter_out_has_cancellation_requests; + + is( $filtered_out_rs->count, 2 ); + is( $filtered_out_rs->next->id, $hold_1->id ); + $schema->storage->txn_rollback; }; --