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

(-)a/C4/Reserves.pm (-17 / +15 lines)
Lines 484-494 sub CanItemBeReserved { Link Here
484
        }
484
        }
485
    }
485
    }
486
486
487
    # must check the notforloan setting of the itemtype
488
    # FIXME - a lot of places in the code do this
489
    #         or something similar - need to be
490
    #         consolidated
491
    my $itemtype = $item->effective_itemtype;
492
    return { status => 'missing_itemtype' }
493
      unless defined $itemtype;
494
    my $notforloan_per_itemtype = Koha::ItemTypes->find($itemtype)->notforloan;
495
496
    return { status => 'notforloan' } if ( $item->notforloan > 0 || $notforloan_per_itemtype );
497
    return { status => 'itemlost' } if $item->itemlost;
498
    return { status => 'withdrawn' } if $item->withdrawn;
487
    # If an item is damaged and we don't allow holds on damaged items, we can stop right here
499
    # If an item is damaged and we don't allow holds on damaged items, we can stop right here
488
    return _cache { status =>'damaged' }
500
    return _cache { status =>'damaged' }
489
      if ( $item->damaged
501
      if ( $item->damaged
490
        && !C4::Context->preference('AllowHoldsOnDamagedItems') );
502
        && !C4::Context->preference('AllowHoldsOnDamagedItems') );
491
503
504
    # we retrieve borrowers information #
505
    my $borrower = $patron->unblessed;
506
492
    if( GetMarcFromKohaField('biblioitems.agerestriction') ){
507
    if( GetMarcFromKohaField('biblioitems.agerestriction') ){
493
        my $biblio = $item->biblio;
508
        my $biblio = $item->biblio;
494
        # Check for the age restriction
509
        # Check for the age restriction
Lines 1330-1352 sub IsAvailableForItemLevelRequest { Link Here
1330
    my $patron              = shift;
1345
    my $patron              = shift;
1331
    my $pickup_branchcode   = shift;
1346
    my $pickup_branchcode   = shift;
1332
1347
1333
    my $dbh = C4::Context->dbh;
1334
    # must check the notforloan setting of the itemtype
1335
    # FIXME - a lot of places in the code do this
1336
    #         or something similar - need to be
1337
    #         consolidated
1338
    my $itemtype = $item->effective_itemtype;
1339
    return 0
1340
      unless defined $itemtype;
1341
    my $notforloan_per_itemtype = Koha::ItemTypes->find($itemtype)->notforloan;
1342
1343
    return 0 if
1344
        $notforloan_per_itemtype ||
1345
        $item->itemlost        ||
1346
        $item->notforloan > 0  || # item with negative or zero notforloan value is holdable
1347
        $item->withdrawn        ||
1348
        ($item->damaged && !C4::Context->preference('AllowHoldsOnDamagedItems'));
1349
1350
    if ($pickup_branchcode) {
1348
    if ($pickup_branchcode) {
1351
        my $destination = Koha::Libraries->find($pickup_branchcode);
1349
        my $destination = Koha::Libraries->find($pickup_branchcode);
1352
        return 0 unless $destination;
1350
        return 0 unless $destination;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (+4 lines)
Lines 904-909 Link Here
904
                                                                        <span>No valid pickup location</span>
904
                                                                        <span>No valid pickup location</span>
905
                                                                    [% ELSIF itemloo.not_holdable == 'notforloan' %]
905
                                                                    [% ELSIF itemloo.not_holdable == 'notforloan' %]
906
                                                                        <span>Not for loan</span>
906
                                                                        <span>Not for loan</span>
907
                                                                    [% ELSIF itemloo.not_holdable == 'withdrawn' %]
908
                                                                        <span>Item has been withdrawn</span>
909
                                                                    [% ELSIF itemloo.not_holdable == 'itemlost' %]
910
                                                                        <span>Item has been marked lost</span>
907
                                                                    [% ELSE %]
911
                                                                    [% ELSE %]
908
                                                                        <span>[% itemloo.not_holdable | html %]</span>
912
                                                                        <span>[% itemloo.not_holdable | html %]</span>
909
                                                                    [% END %]
913
                                                                    [% END %]
(-)a/t/db_dependent/Reserves.t (-7 / +1 lines)
Lines 1452-1458 $schema->storage->txn_rollback(); Link Here
1452
1452
1453
subtest 'IsAvailableForItemLevelRequest() tests' => sub {
1453
subtest 'IsAvailableForItemLevelRequest() tests' => sub {
1454
1454
1455
    plan tests => 3;
1455
    plan tests => 2;
1456
1456
1457
    $schema->storage->txn_begin;
1457
    $schema->storage->txn_begin;
1458
1458
Lines 1465-1475 subtest 'IsAvailableForItemLevelRequest() tests' => sub { Link Here
1465
1465
1466
    my $item = $builder->build_sample_item;
1466
    my $item = $builder->build_sample_item;
1467
1467
1468
    ok(
1469
        !C4::Reserves::IsAvailableForItemLevelRequest( $item, $patron ),
1470
        "Item not available for item-level hold because no effective item type"
1471
    );
1472
1473
    # Weird use case to highlight issue
1468
    # Weird use case to highlight issue
1474
    $item_type = '0';
1469
    $item_type = '0';
1475
    Koha::ItemTypes->search( { itemtype => $item_type } )->delete;
1470
    Koha::ItemTypes->search( { itemtype => $item_type } )->delete;
1476
- 

Return to bug 32702