Browse Source

Bug 21260: Introduce local pref to affect status grouping

Introducing a local preference Available_NFL to control which not for
loan statuses are considered to be 'available for reference'.
Standard value is '1|2' which comes down to the former >0 when using
the initial Koha defaults.

Test plan:
[1] Pick a biblio with an available item A, an item B with notforloan 1,
    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).
[2] Add local pref Available_NFL with value '1'. Repeat the search.
    You should see now:
        Available: A. Reference: B. Not-available: S.C.(1), Damaged(2).
    [where S.C. stands for Staff Collection]
[3] Run test t/db_dependent/XSLT.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: ava li <rubyli208@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Marcel de Rooy 4 years ago
committed by Jonathan Druart
parent
commit
07741c30b6
  1. 11
      C4/XSLT.pm
  2. 12
      t/db_dependent/XSLT.t

11
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 {

12
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{<status>reference</status>},"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{<status>reallynotforloan</status>},"reallynotforloan when we change Avaiable_NFL");
t::lib::Mocks::mock_preference('Available_NFL', '1|2');
}
$item->onloan('2001-01-01')->store;

Loading…
Cancel
Save