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

(-)a/Koha/Holds.pm (+15 lines)
Lines 163-168 sub filter_by_has_cancellation_requests { Link Here
163
        { join => 'cancellation_requests' } );
163
        { join => 'cancellation_requests' } );
164
}
164
}
165
165
166
=head3 filter_out_has_cancellation_requests
167
168
    my $holds_without_cancellation_requests = $holds->filter_out_has_cancellation_requests;
169
170
Returns a filtered resultset without holds with cancellation requests.
171
172
=cut
173
174
sub filter_out_has_cancellation_requests {
175
    my ($self) = @_;
176
177
    return $self->search( { 'hold_cancellation_request_id' => { '=' => undef } },
178
        { join => 'cancellation_requests' } );
179
}
180
166
=head2 Internal methods
181
=head2 Internal methods
167
182
168
=head3 _type
183
=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>Cancelled</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 326-332 if ($show_barcode) { Link Here
326
$template->param( show_barcode => 1 ) if $show_barcode;
326
$template->param( show_barcode => 1 ) if $show_barcode;
327
327
328
# now the reserved items....
328
# now the reserved items....
329
my $reserves = Koha::Holds->search( { borrowernumber => $borrowernumber } );
329
my $reserves = $patron->holds->filter_out_has_cancellation_requests;
330
330
331
$template->param(
331
$template->param(
332
    RESERVES       => $reserves,
332
    RESERVES       => $reserves,
(-)a/t/db_dependent/Koha/Holds.t (-3 / +11 lines)
Lines 644-652 subtest 'set_waiting+patron_expiration_date' => sub { Link Here
644
644
645
$schema->storage->txn_rollback;
645
$schema->storage->txn_rollback;
646
646
647
subtest 'filter_by_has_cancellation_requests() tests' => sub {
647
subtest 'filter_by_has_cancellation_requests() and filter_out_has_cancellation_requests() tests' => sub {
648
648
649
    plan tests => 4;
649
    plan tests => 7;
650
650
651
    $schema->storage->txn_begin;
651
    $schema->storage->txn_begin;
652
652
Lines 699-704 subtest 'filter_by_has_cancellation_requests() tests' => sub { Link Here
699
699
700
    is( $filtered_rs->count, 0 );
700
    is( $filtered_rs->count, 0 );
701
701
702
    my $filtered_out_rs = $rs->filter_out_has_cancellation_requests;
703
704
    is( $filtered_out_rs->count, 3 );
705
702
    $hold_2->add_cancellation_request;
706
    $hold_2->add_cancellation_request;
703
707
704
    $filtered_rs = $rs->filter_by_has_cancellation_requests;
708
    $filtered_rs = $rs->filter_by_has_cancellation_requests;
Lines 706-710 subtest 'filter_by_has_cancellation_requests() tests' => sub { Link Here
706
    is( $filtered_rs->count,    1 );
710
    is( $filtered_rs->count,    1 );
707
    is( $filtered_rs->next->id, $hold_2->id );
711
    is( $filtered_rs->next->id, $hold_2->id );
708
712
713
    $filtered_out_rs = $rs->filter_out_has_cancellation_requests;
714
715
    is( $filtered_out_rs->count,    2 );
716
    is( $filtered_out_rs->next->id, $hold_1->id );
717
709
    $schema->storage->txn_rollback;
718
    $schema->storage->txn_rollback;
710
};
719
};
711
- 

Return to bug 22456