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

(-)a/C4/Reserves.pm (-20 / +15 lines)
Lines 486-500 sub CanItemBeReserved { Link Here
486
        }
486
        }
487
    }
487
    }
488
488
489
    # we retrieve borrowers and items informations #
490
    # item->{itype} will come for biblioitems if necessery
491
    my $borrower = $patron->unblessed;
492
489
490
    # must check the notforloan setting of the itemtype
491
    # FIXME - a lot of places in the code do this
492
    #         or something similar - need to be
493
    #         consolidated
494
    my $itemtype = $item->effective_itemtype;
495
    return { status => 'missing_itemtype' }
496
      unless defined $itemtype;
497
    my $notforloan_per_itemtype = Koha::ItemTypes->find($itemtype)->notforloan;
498
499
    return { status => 'notforloan' } if ( $item->notforloan > 0 || $notforloan_per_itemtype );
500
    return { status => 'itemlost' } if $item->itemlost;
501
    return { status => 'withdrawn' } if $item->withdrawn;
493
    # If an item is damaged and we don't allow holds on damaged items, we can stop right here
502
    # If an item is damaged and we don't allow holds on damaged items, we can stop right here
494
    return _cache { status =>'damaged' }
503
    return _cache { status =>'damaged' }
495
      if ( $item->damaged
504
      if ( $item->damaged
496
        && !C4::Context->preference('AllowHoldsOnDamagedItems') );
505
        && !C4::Context->preference('AllowHoldsOnDamagedItems') );
497
506
507
    # we retrieve borrowers information #
508
    my $borrower = $patron->unblessed;
509
498
    if( GetMarcFromKohaField('biblioitems.agerestriction') ){
510
    if( GetMarcFromKohaField('biblioitems.agerestriction') ){
499
        my $biblio = $item->biblio;
511
        my $biblio = $item->biblio;
500
        # Check for the age restriction
512
        # Check for the age restriction
Lines 1371-1393 sub IsAvailableForItemLevelRequest { Link Here
1371
    my $patron              = shift;
1383
    my $patron              = shift;
1372
    my $pickup_branchcode   = shift;
1384
    my $pickup_branchcode   = shift;
1373
1385
1374
    my $dbh = C4::Context->dbh;
1375
    # must check the notforloan setting of the itemtype
1376
    # FIXME - a lot of places in the code do this
1377
    #         or something similar - need to be
1378
    #         consolidated
1379
    my $itemtype = $item->effective_itemtype;
1380
    return 0
1381
      unless defined $itemtype;
1382
    my $notforloan_per_itemtype = Koha::ItemTypes->find($itemtype)->notforloan;
1383
1384
    return 0 if
1385
        $notforloan_per_itemtype ||
1386
        $item->itemlost        ||
1387
        $item->notforloan > 0  || # item with negative or zero notforloan value is holdable
1388
        $item->withdrawn        ||
1389
        ($item->damaged && !C4::Context->preference('AllowHoldsOnDamagedItems'));
1390
1391
    if ($pickup_branchcode) {
1386
    if ($pickup_branchcode) {
1392
        my $destination = Koha::Libraries->find($pickup_branchcode);
1387
        my $destination = Koha::Libraries->find($pickup_branchcode);
1393
        return 0 unless $destination;
1388
        return 0 unless $destination;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (+4 lines)
Lines 783-788 Link Here
783
                                                                    <span>No valid pickup location</span>
783
                                                                    <span>No valid pickup location</span>
784
                                                                [% ELSIF itemloo.not_holdable == 'notforloan' %]
784
                                                                [% ELSIF itemloo.not_holdable == 'notforloan' %]
785
                                                                    <span>Not for loan</span>
785
                                                                    <span>Not for loan</span>
786
                                                                [% ELSIF itemloo.not_holdable == 'withdrawn' %]
787
                                                                    <span>Item has been withdrawn</span>
788
                                                                [% ELSIF itemloo.not_holdable == 'itemlost' %]
789
                                                                    <span>Item has been marked lost</span>
786
                                                                [% ELSE %]
790
                                                                [% ELSE %]
787
                                                                    <span>[% itemloo.not_holdable | html %]</span>
791
                                                                    <span>[% itemloo.not_holdable | html %]</span>
788
                                                                [% END %]
792
                                                                [% END %]
(-)a/t/db_dependent/Reserves.t (-7 / +1 lines)
Lines 1453-1459 $schema->storage->txn_rollback(); Link Here
1453
1453
1454
subtest 'IsAvailableForItemLevelRequest() tests' => sub {
1454
subtest 'IsAvailableForItemLevelRequest() tests' => sub {
1455
1455
1456
    plan tests => 3;
1456
    plan tests => 2;
1457
1457
1458
    $schema->storage->txn_begin;
1458
    $schema->storage->txn_begin;
1459
1459
Lines 1466-1476 subtest 'IsAvailableForItemLevelRequest() tests' => sub { Link Here
1466
1466
1467
    my $item = $builder->build_sample_item;
1467
    my $item = $builder->build_sample_item;
1468
1468
1469
    ok(
1470
        !C4::Reserves::IsAvailableForItemLevelRequest( $item, $patron ),
1471
        "Item not available for item-level hold because no effective item type"
1472
    );
1473
1474
    # Weird use case to highlight issue
1469
    # Weird use case to highlight issue
1475
    $item_type = '0';
1470
    $item_type = '0';
1476
    Koha::ItemTypes->search( { itemtype => $item_type } )->delete;
1471
    Koha::ItemTypes->search( { itemtype => $item_type } )->delete;
1477
- 

Return to bug 32702