@@ -, +, @@ an item C with notforloan 2 and two damaged items. (Former patch.) Include it in a OPAC search. You should see: Available: A. Reference: B, C. Not-available: Damaged(2). You should see now: Available: A. Reference: B. Not-available: S.C.(1), Damaged(2). [where S.C. stands for Staff Collection] --- C4/XSLT.pm | 11 ++++++++--- t/db_dependent/XSLT.t | 12 ++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) --- a/C4/XSLT.pm +++ a/C4/XSLT.pm @@ -316,6 +316,7 @@ sub buildKohaItemsNamespace { my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; my $xml = ''; my %descs = map { $_->{authorised_value} => $_ } Koha::AuthorisedValues->get_descriptions_by_koha_field( { kohafield => 'items.notforloan' } ); + my $ref_status = C4::Context->preference('Available_NFL') || '1|2'; for my $item (@items) { my $status; @@ -343,13 +344,17 @@ sub buildKohaItemsNamespace { $status = "Checked out"; } elsif ( $item->notforloan ) { - $status = $item->notforloan < 0 ? "reallynotforloan" : "reference"; - $substatus = exists $descs{$item->notforloan} ? $descs{$item->notforloan}->{opac_description} : "Not for loan_".$item->notforloan; + $status = $item->notforloan =~ /^($ref_status)$/ + ? "reference" + : "reallynotforloan"; + $substatus = exists $descs{$item->notforloan} ? $descs{$item->notforloan}->{opac_description} : "Not for loan"; } elsif ( exists $itemtypes->{ $item->effective_itemtype } && $itemtypes->{ $item->effective_itemtype }->{notforloan} == 1 ) { - $status = "reference"; + $status = "1" =~ /^($ref_status)$/ + ? "reference" + : "reallynotforloan"; $substatus = "Not for loan"; } else { --- a/t/db_dependent/XSLT.t +++ a/t/db_dependent/XSLT.t @@ -34,7 +34,10 @@ my $builder = t::lib::TestBuilder->new; $schema->storage->txn_begin; subtest 'buildKohaItemsNamespace status tests' => sub { - plan tests => 13; + plan tests => 14; + + t::lib::Mocks::mock_preference('Available_NFL', '1|2'); + my $itype = $builder->build_object({ class => 'Koha::ItemTypes' }); my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' }); my $item = $builder->build_sample_item({ itype => $itype->itemtype }); @@ -45,7 +48,6 @@ subtest 'buildKohaItemsNamespace status tests' => sub { # notforloan { - t::lib::Mocks::mock_preference('item-level_itypes', 0); $item->notforloan(0)->store; Koha::ItemTypes->find($item->itype)->notforloan(0)->store; @@ -69,6 +71,12 @@ subtest 'buildKohaItemsNamespace status tests' => sub { $item->notforloan(1)->store; $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); like($xml,qr{reference},"reference if positive notforloan value"); + + # But now make status notforloan==1 count under Not available + t::lib::Mocks::mock_preference('Available_NFL', '2'); + $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); + like($xml,qr{reallynotforloan},"reallynotforloan when we change Avaiable_NFL"); + t::lib::Mocks::mock_preference('Available_NFL', '1|2'); } $item->onloan('2001-01-01')->store; --