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

(-)a/tools/inventory.pl (-6 / +20 lines)
Lines 296-301 if( @scanned_items ) { Link Here
296
296
297
}
297
}
298
298
299
        my @avs = Koha::AuthorisedValues->search(
300
        {   'marc_subfield_structures.kohafield' => { '>' => '' },
301
            'me.authorised_value'                => { '>' => '' },
302
        },
303
        {   join     => { category => 'marc_subfield_structures' },
304
            distinct => ['marc_subfield_structures.kohafield, me.category, frameworkcode, me.authorised_value'],
305
            '+select' => [ 'marc_subfield_structures.kohafield', 'marc_subfield_structures.frameworkcode', 'me.authorised_value', 'me.lib' ],
306
            '+as'     => [ 'kohafield',                          'frameworkcode',                          'authorised_value',    'lib' ],
307
        }
308
    )->as_list;
309
    my $avmapping = { map { $_->get_column('kohafield') . ',' . $_->get_column('frameworkcode') . ',' . $_->get_column('authorised_value') => $_->get_column('lib') } @avs };
310
299
# Report scanned items that are on the wrong place, or have a wrong notforloan
311
# Report scanned items that are on the wrong place, or have a wrong notforloan
300
# status, or are still checked out.
312
# status, or are still checked out.
301
for ( my $i = 0; $i < @scanned_items; $i++ ) {
313
for ( my $i = 0; $i < @scanned_items; $i++ ) {
Lines 306-319 for ( my $i = 0; $i < @scanned_items; $i++ ) { Link Here
306
    my $fc = $item->{'frameworkcode'} || '';
318
    my $fc = $item->{'frameworkcode'} || '';
307
319
308
    # Populating with authorised values description
320
    # Populating with authorised values description
309
    foreach my $field (qw/ location notforloan itemlost damaged withdrawn /) {
321
    foreach (keys %$item) {
310
        my $av = Koha::AuthorisedValues->get_description_by_koha_field(
322
        if (
311
            { frameworkcode => $fc, kohafield => "items.$field", authorised_value => $item->{$field} } );
323
            defined(
312
        if ( $av and defined $item->{$field} and defined $av->{lib} ) {
324
                $avmapping->{ "items.$_," . $fc . "," . ( $item->{$_} // q{} ) }
313
            $item->{$field} = $av->{lib};
325
            )
326
        ) {
327
            $item->{$_} = $avmapping->{"items.$_,".$fc.",".$item->{$_}};
314
        }
328
        }
315
    }
329
    }
316
330
331
317
    # If we have scanned items with a non-matching notforloan value
332
    # If we have scanned items with a non-matching notforloan value
318
    if( none { $item->{'notforloancode'} eq $_ } @notforloans ) {
333
    if( none { $item->{'notforloancode'} eq $_ } @notforloans ) {
319
        $item->{problems}->{changestatus} = 1;
334
        $item->{problems}->{changestatus} = 1;
320
- 

Return to bug 31216