View | Details | Raw Unified | Return to bug 22456
Collapse All | Expand All

(-)a/Koha/Holds.pm (+15 lines)
Lines 160-165 sub filter_by_has_cancellation_requests { Link Here
160
        { join => 'cancellation_requests' } );
160
        { join => 'cancellation_requests' } );
161
}
161
}
162
162
163
=head3 filter_out_has_cancellation_requests
164
165
    my $holds_without_cancellation_requests = $holds->filter_out_has_cancellation_requests;
166
167
Returns a filtered resultset without holds with cancellation requests.
168
169
=cut
170
171
sub filter_out_has_cancellation_requests {
172
    my ($self) = @_;
173
174
    return $self->search( { 'hold_cancellation_request_id' => { '=' => undef } },
175
        { join => 'cancellation_requests' } );
176
}
177
163
=head2 Internal methods
178
=head2 Internal methods
164
179
165
=head3 _type
180
=head3 _type
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc (-3 / +1 lines)
Lines 156-169 Link Here
156
                                        <input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
156
                                        <input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
157
                                        <button data-title="[% INCLUDE 'biblio-title-head.inc' biblio=HOLD.biblio %]" data-reserve_id="[% HOLD.reserve_id | html %]" type="submit" class="btn btn-sm btn-danger btn-delete-hold"><i class="fa fa-remove" aria-hidden="true"></i> [% tp('Cancel hold button', 'Cancel') | html %]</button>
157
                                        <button data-title="[% INCLUDE 'biblio-title-head.inc' biblio=HOLD.biblio %]" data-reserve_id="[% HOLD.reserve_id | html %]" type="submit" class="btn btn-sm btn-danger btn-delete-hold"><i class="fa fa-remove" aria-hidden="true"></i> [% tp('Cancel hold button', 'Cancel') | html %]</button>
158
                                    </form>
158
                                    </form>
159
                                [% ELSIF HOLD.cancellation_requests.count > 0 %]
160
                                    <button type="submit" class="btn btn-sm btn-danger disabled"><i class="fa fa-remove" aria-hidden="true"></i> [% t('Cancellation requested') | html %]</button>
161
                                [% ELSIF HOLD.is_waiting && HOLD.cancellation_requestable_from_opac %]
159
                                [% ELSIF HOLD.is_waiting && HOLD.cancellation_requestable_from_opac %]
162
                                    <form id="req_cancel_hold_[% HOLD.reserve_id | html %]" action="/cgi-bin/koha/opac-modrequest.pl" method="post">
160
                                    <form id="req_cancel_hold_[% HOLD.reserve_id | html %]" action="/cgi-bin/koha/opac-modrequest.pl" method="post">
163
                                        <input type="hidden" name="biblionumber" value="[% HOLD.biblionumber | html %]" />
161
                                        <input type="hidden" name="biblionumber" value="[% HOLD.biblionumber | html %]" />
164
                                        <input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
162
                                        <input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
165
                                        <input type="hidden" name="cancellation_request" value="1" />
163
                                        <input type="hidden" name="cancellation_request" value="1" />
166
                                        <button data-title="[% INCLUDE 'biblio-title-head.inc' biblio=HOLD.biblio %]" data-reserve_id="[% HOLD.reserve_id | html %]" type="submit" class="btn btn-sm btn-danger btn-req-delete-hold"><i class="fa fa-remove" aria-hidden="true"></i> [% tp('Cancellation request hold button', 'Request cancellation') | html %]</button>
164
                                        <button data-title="[% INCLUDE 'biblio-title-head.inc' biblio=HOLD.biblio %]" data-reserve_id="[% HOLD.reserve_id | html %]" type="submit" class="btn btn-sm btn-danger btn-req-delete-hold"><i class="fa fa-remove" aria-hidden="true"></i> [% tp('Cancel hold button', 'Cancel') | html %]</button>
167
                                    </form>
165
                                    </form>
168
                                [% END %]
166
                                [% END %]
169
                            </td>
167
                            </td>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt (-1 / +5 lines)
Lines 153-159 Link Here
153
                                        [% ELSIF hold.cancellationdate %]
153
                                        [% ELSIF hold.cancellationdate %]
154
                                            <span>Cancelled</span>
154
                                            <span>Cancelled</span>
155
                                        [% ELSIF hold.found == 'W' %]
155
                                        [% ELSIF hold.found == 'W' %]
156
                                            <span>Waiting</span>
156
                                            [% IF hold.cancellation_requests.count == 0 %]
157
                                                <span>Waiting</span>
158
                                            [% ELSE %]
159
                                                <span>Waiting (cancellation requested)</span>
160
                                            [% END %]
157
                                        [% ELSIF hold.found == 'T' %]
161
                                        [% ELSIF hold.found == 'T' %]
158
                                            <span>In transit</span>
162
                                            <span>In transit</span>
159
                                        [% ELSE %]
163
                                        [% ELSE %]
(-)a/opac/opac-user.pl (-1 / +1 lines)
Lines 332-338 if ($show_barcode) { Link Here
332
$template->param( show_barcode => 1 ) if $show_barcode;
332
$template->param( show_barcode => 1 ) if $show_barcode;
333
333
334
# now the reserved items....
334
# now the reserved items....
335
my $reserves = Koha::Holds->search( { borrowernumber => $borrowernumber } );
335
my $reserves = $patron->holds->filter_out_has_cancellation_requests;
336
336
337
$template->param(
337
$template->param(
338
    RESERVES       => $reserves,
338
    RESERVES       => $reserves,
(-)a/t/db_dependent/Koha/Holds.t (-3 / +11 lines)
Lines 638-646 subtest 'set_waiting+patron_expiration_date' => sub { Link Here
638
638
639
$schema->storage->txn_rollback;
639
$schema->storage->txn_rollback;
640
640
641
subtest 'filter_by_has_cancellation_requests() tests' => sub {
641
subtest 'filter_by_has_cancellation_requests() and filter_out_has_cancellation_requests() tests' => sub {
642
642
643
    plan tests => 4;
643
    plan tests => 7;
644
644
645
    $schema->storage->txn_begin;
645
    $schema->storage->txn_begin;
646
646
Lines 693-698 subtest 'filter_by_has_cancellation_requests() tests' => sub { Link Here
693
693
694
    is( $filtered_rs->count, 0 );
694
    is( $filtered_rs->count, 0 );
695
695
696
    my $filtered_out_rs = $rs->filter_out_has_cancellation_requests;
697
698
    is( $filtered_out_rs->count, 3 );
699
696
    $hold_2->add_cancellation_request;
700
    $hold_2->add_cancellation_request;
697
701
698
    $filtered_rs = $rs->filter_by_has_cancellation_requests;
702
    $filtered_rs = $rs->filter_by_has_cancellation_requests;
Lines 700-704 subtest 'filter_by_has_cancellation_requests() tests' => sub { Link Here
700
    is( $filtered_rs->count,    1 );
704
    is( $filtered_rs->count,    1 );
701
    is( $filtered_rs->next->id, $hold_2->id );
705
    is( $filtered_rs->next->id, $hold_2->id );
702
706
707
    $filtered_out_rs = $rs->filter_out_has_cancellation_requests;
708
709
    is( $filtered_out_rs->count,    2 );
710
    is( $filtered_out_rs->next->id, $hold_1->id );
711
703
    $schema->storage->txn_rollback;
712
    $schema->storage->txn_rollback;
704
};
713
};
705
- 

Return to bug 22456