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

(-)a/Koha/Exceptions/Item/Bundle.pm (+4 lines)
Lines 31-36 use Exception::Class ( Link Here
31
        isa         => 'Koha::Exceptions::Item::Bundle',
31
        isa         => 'Koha::Exceptions::Item::Bundle',
32
        description => 'Someone tried to add a checked out item to a bundle',
32
        description => 'Someone tried to add a checked out item to a bundle',
33
    },
33
    },
34
    'Koha::Exceptions::Item::Bundle::ItemHasHolds' => {
35
        isa         => 'Koha::Exceptions::Item::Bundle',
36
        description => 'Someone tried to add a reserved item to a bundle',
37
    },
34
);
38
);
35
39
36
=head1 NAME
40
=head1 NAME
(-)a/Koha/Item.pm (+7 lines)
Lines 1734-1739 sub add_to_bundle { Link Here
1734
                    }
1734
                    }
1735
                }
1735
                }
1736
1736
1737
                my $holds = $bundle_item->current_holds;
1738
                if ($holds->count) {
1739
                    unless ($options->{ignore_holds}) {
1740
                        Koha::Exceptions::Item::Bundle::ItemHasHolds->throw();
1741
                    }
1742
                }
1743
1737
                $self->_result->add_to_item_bundles_hosts(
1744
                $self->_result->add_to_item_bundles_hosts(
1738
                    { item => $bundle_item->itemnumber } );
1745
                    { item => $bundle_item->itemnumber } );
1739
1746
(-)a/Koha/REST/V1/Items.pm (-2 / +16 lines)
Lines 278-285 sub add_to_bundle { Link Here
278
    }
278
    }
279
279
280
    return try {
280
    return try {
281
        my $force_checkin = $c->validation->param('body')->{'force_checkin'};
281
        my $body = $c->validation->param('body');
282
        my $link = $item->add_to_bundle($bundle_item, { force_checkin => $force_checkin });
282
        my $options = {
283
            force_checkin => $body->{force_checkin},
284
            ignore_holds => $body->{ignore_holds},
285
        };
286
287
        my $link = $item->add_to_bundle($bundle_item, $options);
283
        return $c->render(
288
        return $c->render(
284
            status  => 201,
289
            status  => 201,
285
            openapi => $bundle_item
290
            openapi => $bundle_item
Lines 315-320 sub add_to_bundle { Link Here
315
                }
320
                }
316
            );
321
            );
317
        }
322
        }
323
        elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::ItemHasHolds' ) {
324
            return $c->render(
325
                status  => 409,
326
                openapi => {
327
                    error      => 'Item is reserved',
328
                    error_code => 'reserved'
329
                }
330
            );
331
        }
318
        elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::IsBundle' ) {
332
        elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::IsBundle' ) {
319
            return $c->render(
333
            return $c->render(
320
                status  => 400,
334
                status  => 400,
(-)a/api/v1/swagger/definitions/bundle_link.yaml (+4 lines)
Lines 15-18 properties: Link Here
15
    type:
15
    type:
16
      - boolean
16
      - boolean
17
      - "null"
17
      - "null"
18
  ignore_holds:
19
    type:
20
      - boolean
21
      - "null"
18
additionalProperties: false
22
additionalProperties: false
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +12 lines)
Lines 1976-1981 Note that permanent location is a code, and location may be an authval. Link Here
1976
                                .empty()
1976
                                .empty()
1977
                                .attr('class', 'alert alert-danger')
1977
                                .attr('class', 'alert alert-danger')
1978
                                .append(__x('Failure: Item {barcode} cannot be checked in', { barcode }))
1978
                                .append(__x('Failure: Item {barcode} cannot be checked in', { barcode }))
1979
                          } else if (response.error_code === 'reserved') {
1980
                              const button = $('<button type="button">')
1981
                                .addClass('btn btn-xs')
1982
                                .text(__('Ignore holds and add to bundle'))
1983
                                .on('click', function () {
1984
                                    addToBundle(url, { external_id: barcode, ignore_holds: true });
1985
                                });
1986
                              $('#addResult')
1987
                                .empty()
1988
                                .attr('class', 'alert alert-warning')
1989
                                .append(__x('Warning: Item {barcode} is reserved', { barcode }))
1990
                                .append(' ', button);
1979
                          } else {
1991
                          } else {
1980
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' belongs to another bundle").format(barcode)+'</div>');
1992
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' belongs to another bundle").format(barcode)+'</div>');
1981
                          }
1993
                          }
1982
- 

Return to bug 33021