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

(-)a/C4/XSLT.pm (-3 / +8 lines)
Lines 316-321 sub buildKohaItemsNamespace { Link Here
316
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
316
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
317
    my $xml = '';
317
    my $xml = '';
318
    my %descs = map { $_->{authorised_value} => $_ } Koha::AuthorisedValues->get_descriptions_by_koha_field( { kohafield => 'items.notforloan' } );
318
    my %descs = map { $_->{authorised_value} => $_ } Koha::AuthorisedValues->get_descriptions_by_koha_field( { kohafield => 'items.notforloan' } );
319
    my $ref_status = C4::Context->preference('Available_NFL') || '1|2';
319
320
320
    for my $item (@items) {
321
    for my $item (@items) {
321
        my $status;
322
        my $status;
Lines 343-355 sub buildKohaItemsNamespace { Link Here
343
            $status = "Checked out";
344
            $status = "Checked out";
344
        }
345
        }
345
        elsif ( $item->notforloan ) {
346
        elsif ( $item->notforloan ) {
346
                $status = $item->notforloan < 0 ? "reallynotforloan" : "reference";
347
            $status = $item->notforloan =~ /^($ref_status)$/
347
                $substatus = exists $descs{$item->notforloan} ? $descs{$item->notforloan}->{opac_description} : "Not for loan_".$item->notforloan;
348
                ? "reference"
349
                : "reallynotforloan";
350
            $substatus = exists $descs{$item->notforloan} ? $descs{$item->notforloan}->{opac_description} : "Not for loan";
348
        }
351
        }
349
        elsif ( exists $itemtypes->{ $item->effective_itemtype }
352
        elsif ( exists $itemtypes->{ $item->effective_itemtype }
350
            && $itemtypes->{ $item->effective_itemtype }->{notforloan} == 1 )
353
            && $itemtypes->{ $item->effective_itemtype }->{notforloan} == 1 )
351
        {
354
        {
352
            $status = "reference";
355
            $status = "1" =~ /^($ref_status)$/
356
                ? "reference"
357
                : "reallynotforloan";
353
            $substatus = "Not for loan";
358
            $substatus = "Not for loan";
354
        }
359
        }
355
        else {
360
        else {
(-)a/t/db_dependent/XSLT.t (-3 / +10 lines)
Lines 34-40 my $builder = t::lib::TestBuilder->new; Link Here
34
$schema->storage->txn_begin;
34
$schema->storage->txn_begin;
35
35
36
subtest 'buildKohaItemsNamespace status tests' => sub {
36
subtest 'buildKohaItemsNamespace status tests' => sub {
37
    plan tests => 13;
37
    plan tests => 14;
38
39
    t::lib::Mocks::mock_preference('Available_NFL', '1|2');
40
38
    my $itype = $builder->build_object({ class => 'Koha::ItemTypes' });
41
    my $itype = $builder->build_object({ class => 'Koha::ItemTypes' });
39
    my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' });
42
    my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' });
40
    my $item  = $builder->build_sample_item({ itype => $itype->itemtype });
43
    my $item  = $builder->build_sample_item({ itype => $itype->itemtype });
Lines 45-51 subtest 'buildKohaItemsNamespace status tests' => sub { Link Here
45
48
46
    # notforloan
49
    # notforloan
47
    {
50
    {
48
49
        t::lib::Mocks::mock_preference('item-level_itypes', 0);
51
        t::lib::Mocks::mock_preference('item-level_itypes', 0);
50
        $item->notforloan(0)->store;
52
        $item->notforloan(0)->store;
51
        Koha::ItemTypes->find($item->itype)->notforloan(0)->store;
53
        Koha::ItemTypes->find($item->itype)->notforloan(0)->store;
Lines 69-74 subtest 'buildKohaItemsNamespace status tests' => sub { Link Here
69
        $item->notforloan(1)->store;
71
        $item->notforloan(1)->store;
70
        $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
72
        $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
71
        like($xml,qr{<status>reference</status>},"reference if positive notforloan value");
73
        like($xml,qr{<status>reference</status>},"reference if positive notforloan value");
74
75
        # But now make status notforloan==1 count under Not available
76
        t::lib::Mocks::mock_preference('Available_NFL', '2');
77
        $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
78
        like($xml,qr{<status>reallynotforloan</status>},"reallynotforloan when we change Avaiable_NFL");
79
        t::lib::Mocks::mock_preference('Available_NFL', '1|2');
72
    }
80
    }
73
81
74
    $item->onloan('2001-01-01')->store;
82
    $item->onloan('2001-01-01')->store;
75
- 

Return to bug 21260