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

(-)a/C4/Reserves.pm (-20 / +15 lines)
Lines 451-465 sub CanItemBeReserved { Link Here
451
        }
451
        }
452
    }
452
    }
453
453
454
    # we retrieve borrowers and items informations #
455
    # item->{itype} will come for biblioitems if necessery
456
    my $borrower = $patron->unblessed;
457
454
455
    # must check the notforloan setting of the itemtype
456
    # FIXME - a lot of places in the code do this
457
    #         or something similar - need to be
458
    #         consolidated
459
    my $itemtype = $item->effective_itemtype;
460
    return { status => 'missing_itemtype' }
461
      unless defined $itemtype;
462
    my $notforloan_per_itemtype = Koha::ItemTypes->find($itemtype)->notforloan;
463
464
    return { status => 'notforloan' } if ( $item->notforloan > 0 || $notforloan_per_itemtype );
465
    return { status => 'itemlost' } if $item->itemlost;
466
    return { status => 'withdrawn' } if $item->withdrawn;
458
    # If an item is damaged and we don't allow holds on damaged items, we can stop right here
467
    # If an item is damaged and we don't allow holds on damaged items, we can stop right here
459
    return _cache { status =>'damaged' }
468
    return _cache { status =>'damaged' }
460
      if ( $item->damaged
469
      if ( $item->damaged
461
        && !C4::Context->preference('AllowHoldsOnDamagedItems') );
470
        && !C4::Context->preference('AllowHoldsOnDamagedItems') );
462
471
472
    # we retrieve borrowers information #
473
    my $borrower = $patron->unblessed;
474
463
    if( GetMarcFromKohaField('biblioitems.agerestriction') ){
475
    if( GetMarcFromKohaField('biblioitems.agerestriction') ){
464
        my $biblio = $item->biblio;
476
        my $biblio = $item->biblio;
465
        # Check for the age restriction
477
        # Check for the age restriction
Lines 1336-1358 sub IsAvailableForItemLevelRequest { Link Here
1336
    my $patron              = shift;
1348
    my $patron              = shift;
1337
    my $pickup_branchcode   = shift;
1349
    my $pickup_branchcode   = shift;
1338
1350
1339
    my $dbh = C4::Context->dbh;
1340
    # must check the notforloan setting of the itemtype
1341
    # FIXME - a lot of places in the code do this
1342
    #         or something similar - need to be
1343
    #         consolidated
1344
    my $itemtype = $item->effective_itemtype;
1345
    return 0
1346
      unless defined $itemtype;
1347
    my $notforloan_per_itemtype = Koha::ItemTypes->find($itemtype)->notforloan;
1348
1349
    return 0 if
1350
        $notforloan_per_itemtype ||
1351
        $item->itemlost        ||
1352
        $item->notforloan > 0  || # item with negative or zero notforloan value is holdable
1353
        $item->withdrawn        ||
1354
        ($item->damaged && !C4::Context->preference('AllowHoldsOnDamagedItems'));
1355
1356
    if ($pickup_branchcode) {
1351
    if ($pickup_branchcode) {
1357
        my $destination = Koha::Libraries->find($pickup_branchcode);
1352
        my $destination = Koha::Libraries->find($pickup_branchcode);
1358
        return 0 unless $destination;
1353
        return 0 unless $destination;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (+4 lines)
Lines 782-787 Link Here
782
                                                                    <span>No valid pickup location</span>
782
                                                                    <span>No valid pickup location</span>
783
                                                                [% ELSIF itemloo.not_holdable == 'notforloan' %]
783
                                                                [% ELSIF itemloo.not_holdable == 'notforloan' %]
784
                                                                    <span>Not for loan</span>
784
                                                                    <span>Not for loan</span>
785
                                                                [% ELSIF itemloo.not_holdable == 'withdrawn' %]
786
                                                                    <span>Item has been withdrawn</span>
787
                                                                [% ELSIF itemloo.not_holdable == 'itemlost' %]
788
                                                                    <span>Item has been marked lost</span>
785
                                                                [% ELSE %]
789
                                                                [% ELSE %]
786
                                                                    <span>[% itemloo.not_holdable | html %]</span>
790
                                                                    <span>[% itemloo.not_holdable | html %]</span>
787
                                                                [% END %]
791
                                                                [% END %]
(-)a/t/db_dependent/Reserves.t (-7 / +1 lines)
Lines 1436-1442 $schema->storage->txn_rollback(); Link Here
1436
1436
1437
subtest 'IsAvailableForItemLevelRequest() tests' => sub {
1437
subtest 'IsAvailableForItemLevelRequest() tests' => sub {
1438
1438
1439
    plan tests => 3;
1439
    plan tests => 2;
1440
1440
1441
    $schema->storage->txn_begin;
1441
    $schema->storage->txn_begin;
1442
1442
Lines 1449-1459 subtest 'IsAvailableForItemLevelRequest() tests' => sub { Link Here
1449
1449
1450
    my $item = $builder->build_sample_item;
1450
    my $item = $builder->build_sample_item;
1451
1451
1452
    ok(
1453
        !C4::Reserves::IsAvailableForItemLevelRequest( $item, $patron ),
1454
        "Item not available for item-level hold because no effective item type"
1455
    );
1456
1457
    # Weird use case to highlight issue
1452
    # Weird use case to highlight issue
1458
    $item_type = '0';
1453
    $item_type = '0';
1459
    Koha::ItemTypes->search( { itemtype => $item_type } )->delete;
1454
    Koha::ItemTypes->search( { itemtype => $item_type } )->delete;
1460
- 

Return to bug 32702